অপারেশন শব্দার্থবিদ্যা

XlaBuilder ইন্টারফেসে সংজ্ঞায়িত ক্রিয়াকলাপের শব্দার্থবিদ্যা নিম্নলিখিত বর্ণনা করে। সাধারণত, এই ক্রিয়াকলাপগুলি xla_data.proto এ RPC ইন্টারফেসে সংজ্ঞায়িত ক্রিয়াকলাপগুলির সাথে একের পর এক ম্যাপ করে।

নামকরণের উপর একটি নোট: সাধারণীকৃত ডেটা টাইপ XLA হল একটি এন-ডাইমেনশনাল অ্যারে যা কিছু ইউনিফর্ম টাইপের উপাদান ধারণ করে (যেমন 32-বিট ফ্লোট)। ডকুমেন্টেশন জুড়ে, অ্যারে একটি অবাধ-মাত্রিক অ্যারে বোঝাতে ব্যবহৃত হয়। সুবিধার জন্য, বিশেষ ক্ষেত্রে আরো নির্দিষ্ট এবং পরিচিত নাম আছে; উদাহরণস্বরূপ একটি ভেক্টর একটি 1-মাত্রিক অ্যারে এবং একটি ম্যাট্রিক্স একটি 2-মাত্রিক অ্যারে।

অ্যাবস

এছাড়াও দেখুন XlaBuilder::Abs

উপাদান-ভিত্তিক abs x -> |x| .

Abs(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ফাংশনের অপারেন্ড

StableHLO তথ্যের জন্য StableHLO - abs দেখুন।

যোগ করুন

এছাড়াও দেখুন XlaBuilder::Add

lhs এবং rhs এর উপাদান-ভিত্তিক যোগ সম্পাদন করে।

Add(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে
rhs XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে

আর্গুমেন্টের আকারগুলি একই রকম বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী সে সম্পর্কে সম্প্রচার ডকুমেন্টেশন দেখুন৷ একটি অপারেশনের ফলাফলের একটি আকৃতি থাকে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই ভেরিয়েন্টে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে ক্রিয়াকলাপগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির একটি একটি স্কেলার হয়।

যোগ করার জন্য ভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক বিদ্যমান:

Add(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে
rhs XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে
সম্প্রচার_মাত্রা ArraySlice লক্ষ্য আকৃতির কোন মাত্রা অপারেন্ড আকৃতির প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিকটি বিভিন্ন র‌্যাঙ্কের অ্যারের মধ্যে গাণিতিক ক্রিয়াকলাপের জন্য ব্যবহার করা উচিত (যেমন একটি ভেক্টরে একটি ম্যাট্রিক্স যোগ করা)।

অতিরিক্ত ব্রডকাস্ট_ডাইমেনশন অপারেন্ড হল পূর্ণসংখ্যার একটি স্লাইস যা অপারেন্ড সম্প্রচারের জন্য ব্যবহার করার মাত্রা নির্দিষ্ট করে। শব্দার্থবিদ্যা সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

StableHLO তথ্যের জন্য StableHLO - যুক্ত দেখুন।

নির্ভরতা যোগ করুন

আরও দেখুন HloInstruction::AddDependency

AddDependency এইচএলও ডাম্পগুলিতে প্রদর্শিত হতে পারে, তবে সেগুলি শেষ ব্যবহারকারীদের দ্বারা ম্যানুয়ালি তৈরি করার উদ্দেশ্যে নয়।

আফটার অল

এছাড়াও দেখুন XlaBuilder::AfterAll

আফটারঅল বিভিন্ন সংখ্যক টোকেন নেয় এবং একটি একক টোকেন তৈরি করে। টোকেন হল আদিম প্রকার যা আদেশ কার্যকর করার জন্য পার্শ্ব-প্রতিক্রিয়াশীল ক্রিয়াকলাপগুলির মধ্যে থ্রেড করা যেতে পারে। AfterAll অপারেশনের একটি সেটের পরে একটি অপারেশন অর্ডার করার জন্য টোকেনের যোগদান হিসাবে ব্যবহার করা যেতে পারে।

AfterAll(tokens)

যুক্তি টাইপ শব্দার্থবিদ্যা
tokens XlaOp এর ভেক্টর টোকেনের বৈচিত্র্যময় সংখ্যা

StableHLO তথ্যের জন্য StableHLO - after_all দেখুন।

অল গ্যাদার

এছাড়াও দেখুন XlaBuilder::AllGather

প্রতিলিপি জুড়ে সংযোগ সঞ্চালন.

AllGather(operand, all_gather_dimension, shard_count, replica_groups, channel_id, layout, use_global_device_ids)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp প্রতিলিপি জুড়ে সংযুক্ত করার জন্য অ্যারে
all_gather_dimension int64 সংযুক্তি মাত্রা
shard_count int64 প্রতিটি রেপ্লিকা গ্রুপের আকার
replica_groups int64 এর ভেক্টরের ভেক্টর যে গোষ্ঠীগুলির মধ্যে সংযোগ সঞ্চালিত হয়৷
channel_id ঐচ্ছিক ChannelHandle ক্রস-মডিউল যোগাযোগের জন্য ঐচ্ছিক চ্যানেল আইডি
layout ঐচ্ছিক Layout একটি লেআউট প্যাটার্ন তৈরি করে যা আর্গুমেন্টে মিলে যাওয়া লেআউটকে ক্যাপচার করবে
use_global_device_ids ঐচ্ছিক bool ReplicaGroup কনফিগারেশনের আইডি যদি একটি বিশ্বব্যাপী আইডি উপস্থাপন করে তাহলে সত্য দেখায়
  • replica_groups হল প্রতিরূপ গোষ্ঠীর একটি তালিকা যার মধ্যে সংযোগ করা হয় (বর্তমান প্রতিরূপের জন্য প্রতিলিপি আইডি ReplicaId ব্যবহার করে পুনরুদ্ধার করা যেতে পারে)। প্রতিটি গোষ্ঠীর প্রতিলিপিগুলির ক্রম নির্ধারণ করে যে ক্রমে তাদের ইনপুটগুলি ফলাফলে অবস্থিত। replica_groups হয় খালি হতে হবে (যে ক্ষেত্রে সমস্ত প্রতিলিপি একটি একক গোষ্ঠীর অন্তর্গত, 0 থেকে N - 1 পর্যন্ত অর্ডার করা হয়েছে), অথবা প্রতিলিপির সংখ্যার সমান সংখ্যক উপাদান থাকতে হবে। উদাহরণস্বরূপ, replica_groups = {0, 2}, {1, 3} প্রতিলিপিগুলি 0 এবং 2 , এবং 1 এবং 3 মধ্যে সংযুক্তি সম্পাদন করে।
  • shard_count হল প্রতিটি রেপ্লিকা গ্রুপের আকার। আমাদের এই ক্ষেত্রে প্রয়োজন যেখানে replica_groups খালি থাকে।
  • channel_id ক্রস-মডিউল যোগাযোগের জন্য ব্যবহৃত হয়: একই channel_id দিয়ে শুধুমাত্র all-gather ক্রিয়াকলাপ একে অপরের সাথে যোগাযোগ করতে পারে।
  • use_global_device_ids সত্য প্রত্যাবর্তন করে যদি ReplicaGroup কনফিগারেশনের আইডিগুলি একটি প্রতিলিপি আইডির পরিবর্তে (replica_id * partition_count + partition_id) এর একটি বিশ্বব্যাপী আইডি উপস্থাপন করে। এটি ডিভাইসগুলির আরও নমনীয় গ্রুপিং সক্ষম করে যদি এই অল-রিডুসটি ক্রস-পার্টিশন এবং ক্রস-প্রতিলিপি উভয়ই হয়।

আউটপুট শেপ হল ইনপুট শেপ যা all_gather_dimension দিয়ে shard_count বার বড় করা হয়। উদাহরণস্বরূপ, যদি দুটি প্রতিলিপি থাকে এবং অপারেন্ড দুটি প্রতিলিপিতে যথাক্রমে [1.0, 2.5] এবং [3.0, 5.25] মান থাকে, তাহলে এই অপ থেকে আউটপুট মান যেখানে all_gather_dim 0 হবে উভয় রেপ্লিকে [1.0, 2.5, 3.0,5.25] হবে।

AllGather এর API অভ্যন্তরীণভাবে 2টি HLO নির্দেশাবলীতে ( AllGatherStart এবং AllGatherDone ) বিভক্ত হয়।

আরও দেখুন HloInstruction::CreateAllGatherStart

AllGatherStart , AllGatherDone HLO-তে আদিম হিসেবে কাজ করে। এই অপ্সগুলি HLO ডাম্পগুলিতে প্রদর্শিত হতে পারে, তবে এগুলি শেষ ব্যবহারকারীদের দ্বারা ম্যানুয়ালি তৈরি করার উদ্দেশ্যে নয়।

StableHLO তথ্যের জন্য StableHLO - all_gather দেখুন।

AllReduce

এছাড়াও দেখুন XlaBuilder::AllReduce

প্রতিলিপি জুড়ে একটি কাস্টম গণনা সম্পাদন করে।

AllReduce(operand, computation, replica_groups, channel_id, shape_with_layout, use_global_device_ids)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp রেপ্লিকা জুড়ে কমাতে অ্যারে বা অ্যারের একটি অ-খালি টিপল
computation XlaComputation হ্রাস গণনা
replica_groups ReplicaGroup ভেক্টর যে গ্রুপগুলির মধ্যে হ্রাস করা হয়
channel_id ঐচ্ছিক ChannelHandle ক্রস-মডিউল যোগাযোগের জন্য ঐচ্ছিক চ্যানেল আইডি
shape_with_layout ঐচ্ছিক Shape স্থানান্তরিত ডেটার বিন্যাস সংজ্ঞায়িত করে
use_global_device_ids ঐচ্ছিক bool ReplicaGroup কনফিগারেশনের আইডি যদি একটি বিশ্বব্যাপী আইডি উপস্থাপন করে তাহলে সত্য দেখায়
  • যখন operand অ্যারের একটি টিপল হয়, তখন টিপলের প্রতিটি উপাদানে অল-রিডুস সঞ্চালিত হয়।
  • replica_groups হল প্রতিরূপ গোষ্ঠীর একটি তালিকা যার মধ্যে হ্রাস করা হয় (বর্তমান প্রতিরূপের জন্য প্রতিলিপি আইডি ReplicaId ব্যবহার করে পুনরুদ্ধার করা যেতে পারে)। replica_groups হয় খালি হতে হবে (যে ক্ষেত্রে সমস্ত প্রতিলিপি একটি একক গোষ্ঠীর অন্তর্গত), বা প্রতিলিপির সংখ্যার সমান সংখ্যক উপাদান থাকতে হবে। উদাহরণস্বরূপ, replica_groups = {0, 2}, {1, 3} প্রতিলিপি 0 এবং 2 , এবং 1 এবং 3 মধ্যে হ্রাস সম্পাদন করে।
  • channel_id ক্রস-মডিউল যোগাযোগের জন্য ব্যবহৃত হয়: একই channel_id দিয়ে শুধুমাত্র all-reduce ক্রিয়াকলাপ একে অপরের সাথে যোগাযোগ করতে পারে।
  • shape_with_layout : AllReduce-এর লেআউটকে প্রদত্ত লেআউটে জোর করে। এটি আলাদাভাবে কম্পাইল করা AllReduce ops এর একটি গ্রুপের জন্য একই লেআউটের গ্যারান্টি দিতে ব্যবহৃত হয়।
  • use_global_device_ids সত্য প্রত্যাবর্তন করে যদি ReplicaGroup কনফিগারেশনের আইডিগুলি একটি প্রতিলিপি আইডির পরিবর্তে (replica_id * partition_count + partition_id) এর একটি বিশ্বব্যাপী আইডি উপস্থাপন করে। এটি ডিভাইসগুলির আরও নমনীয় গ্রুপিং সক্ষম করে যদি এই অল-রিডুসটি ক্রস-পার্টিশন এবং ক্রস-প্রতিলিপি উভয়ই হয়।

আউটপুট আকৃতি ইনপুট আকারের মতই। উদাহরণস্বরূপ, যদি দুটি প্রতিলিপি থাকে এবং অপারেন্ড দুটি প্রতিলিপিতে যথাক্রমে [1.0, 2.5] এবং [3.0, 5.25] মান থাকে, তাহলে উভয় প্রতিলিপিতে এই অপ এবং সমষ্টি গণনা থেকে আউটপুট মান হবে [4.0, 7.75] । ইনপুট একটি tuple হলে, আউটপুট একটি tuple পাশাপাশি.

AllReduce এর ফলাফল গণনা করার জন্য প্রতিটি প্রতিলিপি থেকে একটি ইনপুট থাকা প্রয়োজন, তাই যদি একটি প্রতিলিপি একটি AllReduce নোডকে অন্যটির চেয়ে বেশি বার চালায়, তাহলে পূর্বের প্রতিরূপটি চিরতরে অপেক্ষা করবে। যেহেতু প্রতিলিপিগুলি একই প্রোগ্রাম চালাচ্ছে, তাই এটি হওয়ার জন্য অনেকগুলি উপায় নেই, তবে এটি সম্ভব যখন একটি while লুপের অবস্থা infeed ডেটার উপর নির্ভর করে এবং infeed ডেটার কারণে while লুপ একটি প্রতিলিপিতে অন্যটির চেয়ে বেশি বার পুনরাবৃত্তি করে।

AllReduce এর এপিআই অভ্যন্তরীণভাবে 2টি HLO নির্দেশাবলী ( AllReduceStart এবং AllReduceDone ) তে পচে যায়।

আরও দেখুন HloInstruction::CreateAllReduceStart

AllReduceStart এবং AllReduceDone HLO-তে আদিম হিসেবে কাজ করে। এই অপ্সগুলি HLO ডাম্পগুলিতে প্রদর্শিত হতে পারে, তবে এগুলি শেষ ব্যবহারকারীদের দ্বারা ম্যানুয়ালি তৈরি করার উদ্দেশ্যে নয়।

CrossReplicaSum

এছাড়াও দেখুন XlaBuilder::CrossReplicaSum

একটি সমষ্টি গণনা সহ AllReduce সম্পাদন করে।

CrossReplicaSum(operand, replica_groups)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp রেপ্লিকা জুড়ে কমাতে অ্যারে বা অ্যারের একটি অ-খালি টিপল
replica_groups int64 এর ভেক্টরের ভেক্টর যে গ্রুপগুলির মধ্যে হ্রাস করা হয়

প্রতিলিপিগুলির প্রতিটি উপগোষ্ঠীর মধ্যে অপারেন্ড মানের সমষ্টি প্রদান করে। সমস্ত প্রতিলিপি যোগফলের জন্য একটি ইনপুট সরবরাহ করে এবং সমস্ত প্রতিলিপি প্রতিটি উপগোষ্ঠীর জন্য ফলস্বরূপ যোগফল গ্রহণ করে।

AllToAll

এছাড়াও দেখুন XlaBuilder::AllToAll

AllToAll হল একটি যৌথ অপারেশন যা সমস্ত কোর থেকে সমস্ত কোরে ডেটা পাঠায়। এর দুটি পর্যায় রয়েছে:

  1. বিক্ষিপ্ত পর্ব। প্রতিটি কোরে, অপারেন্ডটি split_dimensions বরাবর ব্লকের split_count সংখ্যায় বিভক্ত হয়, এবং ব্লকগুলি সমস্ত কোরে ছড়িয়ে পড়ে, যেমন, ith ব্লকটি ith কোরে পাঠানো হয়।
  2. সংগ্রহ পর্ব। প্রতিটি কোর concat_dimension বরাবর প্রাপ্ত ব্লকগুলিকে সংযুক্ত করে।

অংশগ্রহণকারী কোরগুলি এর দ্বারা কনফিগার করা যেতে পারে:

  • replica_groups : প্রতিটি ReplicaGroup গণনায় অংশগ্রহণকারী প্রতিলিপি আইডিগুলির একটি তালিকা ধারণ করে (বর্তমান প্রতিরূপের জন্য প্রতিরূপ আইডি ReplicaId ব্যবহার করে পুনরুদ্ধার করা যেতে পারে)। AllToAll নির্দিষ্ট ক্রমে সাবগ্রুপের মধ্যে প্রয়োগ করা হবে। উদাহরণস্বরূপ, replica_groups = { {1,2,3}, {4,5,0} } এর মানে হল যে একটি AllToAll প্রতিলিপি {1, 2, 3} মধ্যে প্রয়োগ করা হবে, এবং সংগ্রহের পর্যায়ে, এবং প্রাপ্ত ব্লকগুলি 1, 2, 3 এর একই ক্রমে সংযুক্ত করা হবে। তারপর, অন্য AllToAll প্রয়োগ করা হবে, 4 এবং 5 এর মধ্যে, সংযোজন ক্রমটিও 4, 5, 0। যদি replica_groups খালি থাকে, তবে সমস্ত প্রতিলিপি তাদের উপস্থিতির সংমিশ্রণ ক্রম অনুসারে একটি গ্রুপের অন্তর্গত।

পূর্বশর্ত:

  • split_dimension এর অপারেন্ডের ডাইমেনশন সাইজ split_count দ্বারা বিভাজ্য।
  • অপারেন্ডের আকৃতি টিপল নয়।

AllToAll(operand, split_dimension, concat_dimension, split_count, replica_groups, layout, channel_id)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp n মাত্রিক ইনপুট অ্যারে
split_dimension int64 ব্যবধানে একটি মান [0,n) যা অপারেন্ডটি বিভক্ত করা হয়েছে এমন মাত্রার নাম দেয়
concat_dimension int64 ব্যবধানে একটি মান [0,n) যা বিভক্ত ব্লকগুলিকে সংযুক্ত করা হয়েছে এমন মাত্রার নাম দেয়
split_count int64 এই অপারেশনে অংশগ্রহণকারী কোরের সংখ্যা। যদি replica_groups খালি থাকে, তাহলে এটি প্রতিলিপির সংখ্যা হওয়া উচিত; অন্যথায়, এটি প্রতিটি গ্রুপের প্রতিলিপি সংখ্যার সমান হওয়া উচিত।
replica_groups ReplicaGroup ভেক্টর প্রতিটি গ্রুপে প্রতিলিপি আইডিগুলির একটি তালিকা রয়েছে৷
layout ঐচ্ছিক Layout ব্যবহারকারী-নির্দিষ্ট মেমরি লেআউট
channel_id ঐচ্ছিক ChannelHandle প্রতিটি পাঠান/recv জোড়ার জন্য অনন্য শনাক্তকারী

আকার এবং লেআউট সম্পর্কে আরও তথ্যের জন্য xla::shapes দেখুন। .

StableHLO তথ্যের জন্য StableHLO - all_to_all দেখুন।

AllToAll - উদাহরণ 1.

XlaBuilder b("alltoall");
auto x = Parameter(&b, 0, ShapeUtil::MakeShape(F32, {4, 16}), "x");
AllToAll(
    x,
    /*split_dimension=*/ 1,
    /*concat_dimension=*/ 0,
    /*split_count=*/ 4);

উপরের উদাহরণে, Alltoall-এ 4টি কোর অংশগ্রহণ করছে। প্রতিটি কোরে, অপারেন্ডটি 1 মাত্রা সহ 4টি অংশে বিভক্ত, তাই প্রতিটি অংশের আকার f32[4,4] আছে। 4টি অংশ সমস্ত কোরে ছড়িয়ে ছিটিয়ে রয়েছে। তারপর প্রতিটি কোর কোর 0-4 এর ক্রমানুসারে 0 মাত্রা সহ প্রাপ্ত অংশগুলিকে সংযুক্ত করে। সুতরাং প্রতিটি কোরের আউটপুটের আকার f32[16,4] আছে।

AllToAll - উদাহরণ 2 - StableHLO

StableHLO-এর জন্য AllToAll ডেটাফ্লো-এর একটি উদাহরণ

উপরের উদাহরণে, AllToAll-এ 2টি প্রতিলিপি অংশগ্রহণ করছে। প্রতিটি প্রতিলিপিতে, অপারেন্ডের আকার f32[2,4] আছে। অপারেন্ডটি 1 মাত্রা বরাবর 2টি অংশে বিভক্ত, তাই প্রতিটি অংশের আকার f32[2,2] আছে। 2টি অংশ তারপর প্রতিলিপি গোষ্ঠীতে তাদের অবস্থান অনুযায়ী প্রতিলিপি জুড়ে বিনিময় করা হয়। প্রতিটি প্রতিরূপ উভয় অপারেন্ড থেকে তার সংশ্লিষ্ট অংশ সংগ্রহ করে এবং 0 মাত্রার সাথে সংযুক্ত করে। ফলস্বরূপ, প্রতিটি প্রতিরূপের আউটপুট f32[4,2] আকৃতি ধারণ করে।

RaggedAllToAll

এছাড়াও দেখুন XlaBuilder::RaggedAllToAll

RaggedAllToAll একটি যৌথ অল-টু-অল অপারেশন করে, যেখানে ইনপুট এবং আউটপুট রাগড টেনসর হয়।

RaggedAllToAll(input, input_offsets, send_sizes, output, output_offsets, recv_sizes, replica_groups, channel_id)

যুক্তি টাইপ শব্দার্থবিদ্যা
input XlaOp টাইপ T এর এন অ্যারে
input_offsets XlaOp টাইপ T এর এন অ্যারে
send_sizes XlaOp টাইপ T এর এন অ্যারে
output XlaOp টাইপ T এর এন অ্যারে
output_offsets XlaOp টাইপ T এর এন অ্যারে
recv_sizes XlaOp টাইপ T এর এন অ্যারে
replica_groups ReplicaGroup ভেক্টর প্রতিটি গ্রুপে প্রতিলিপি আইডিগুলির একটি তালিকা রয়েছে৷
channel_id ঐচ্ছিক ChannelHandle প্রতিটি পাঠান/recv জোড়ার জন্য অনন্য শনাক্তকারী

রাগড টেনসরগুলি তিনটি টেনসরের একটি সেট দ্বারা সংজ্ঞায়িত করা হয়:

  • data : data টেনসরটি তার বাইরেরতম মাত্রা বরাবর "র্যাগড" হয়, যার সাথে প্রতিটি সূচীকৃত উপাদানের পরিবর্তনশীল আকার থাকে।
  • offsets ': offsets টেনসর data টেনসরের বাইরেরতম মাত্রাকে সূচী করে এবং data টেনসরের প্রতিটি র‌্যাগড উপাদানের শুরুর অফসেটকে প্রতিনিধিত্ব করে।
  • sizes : sizes টেনসর data টেনসরের প্রতিটি র‍্যাগড উপাদানের আকারকে উপস্থাপন করে, যেখানে আকারটি উপ-উপাদানের এককগুলিতে নির্দিষ্ট করা হয়। একটি উপ-উপাদানকে 'ডেটা' টেনসর আকৃতির প্রত্যয় হিসাবে সংজ্ঞায়িত করা হয় যা বাইরেরতম "র্যাগড" মাত্রা সরিয়ে দিয়ে প্রাপ্ত হয়।
  • offsets এবং sizes টেনসরগুলির অবশ্যই একই আকার থাকতে হবে।

রাগড টেনসরের একটি উদাহরণ:

data: [8,3] =
{ {a,b,c},{d,e,f},{g,h,i},{j,k,l},{m,n,o},{p,q,r},{s,t,u},{v,w,x} }

offsets: [3] = {0, 1, 4}

sizes: [3] = {1, 3, 4}

// Index 'data' at 'offsets'[0], 'sizes'[0]' // {a,b,c}

// Index 'data' at 'offsets'[1], 'sizes'[1]' // {d,e,f},{g,h,i},{j,k,l}

// Index 'data' at 'offsets'[2], 'sizes'[2]' // {m,n,o},{p,q,r},{s,t,u},{v,w,x}

output_offsets এমনভাবে শার্ড করা উচিত যাতে প্রতিটি প্রতিলিপির লক্ষ্য প্রতিলিপি আউটপুট দৃষ্টিকোণে অফসেট থাকে।

i-th আউটপুট অফসেটের জন্য, বর্তমান রেপ্লিকাটি input[input_offsets[i]:input_offsets[i]+input_sizes[i]] আপডেট পাঠাবে i -th প্রতিলিপিতে যা লেখা হবে output_i[output_offsets[i]:output_offsets[i]+send_sizes[i]] output i

উদাহরণস্বরূপ, যদি আমাদের 2টি প্রতিলিপি থাকে:

replica 0:
input: [1, 2, 2]
output:[0, 0, 0, 0]
input_offsets: [0, 1]
send_sizes: [1, 2]
output_offsets: [0, 0]
recv_sizes: [1, 1]

replica 1:
input: [3, 4, 0]
output: [0, 0, 0, 0]
input_offsets: [0, 1]
send_sizes: [1, 1]
output_offsets: [1, 2]
recv_sizes: [2, 1]

// replica 0's result will be: [1, 3, 0, 0]
// replica 1's result will be: [2, 2, 4, 0]

র্যাগড অল-টু-অল এইচএলও-তে নিম্নলিখিত যুক্তি রয়েছে:

  • input : রাগড ইনপুট ডেটা টেনসর।
  • output : রাগড আউটপুট ডেটা টেনসর।
  • input_offsets : রাগড ইনপুট অফসেট টেনসর।
  • send_sizes : রাগড সেন্ড সাইজ টেনসর।
  • output_offsets : টার্গেট রেপ্লিকা আউটপুটে র‌্যাগড অফসেটের অ্যারে।
  • recv_sizes : রাগড recv মাপ টেনসর।

*_offsets এবং *_sizes টেনসরগুলির সকলেরই আকৃতি একই হওয়া আবশ্যক।

দুটি আকার *_offsets এবং *_sizes টেনসরের জন্য সমর্থিত:

  • [num_devices] যেখানে র‍্যাগড-অল-টু-অল রেপ্লিকা গ্রুপের প্রতিটি দূরবর্তী ডিভাইসে সর্বাধিক একটি আপডেট পাঠাতে পারে। যেমন:
for (remote_device_id : replica_group) {
     SEND input[input_offsets[remote_device_id]],
     output[output_offsets[remote_device_id]],
     send_sizes[remote_device_id] }
  • [num_devices, num_updates] যেখানে ragged-all-to-all num_updates পর্যন্ত পাঠাতে পারে একই রিমোট ডিভাইস (প্রতিটি আলাদা অফসেটে), প্রতিরূপ গ্রুপের প্রতিটি দূরবর্তী ডিভাইসের জন্য।

যেমন:

for (remote_device_id : replica_group) {
    for (update_idx : num_updates) {
        SEND input[input_offsets[remote_device_id][update_idx]],
        output[output_offsets[remote_device_id][update_idx]]],
        send_sizes[remote_device_id][update_idx] } }

এবং

এছাড়াও দেখুন XlaBuilder::And

দুটি টেনসর lhs এবং rhs এর উপাদান-ভিত্তিক AND সম্পাদন করে।

And(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে
rhs XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে

আর্গুমেন্টের আকারগুলি একই রকম বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী সে সম্পর্কে সম্প্রচার ডকুমেন্টেশন দেখুন৷ একটি অপারেশনের ফলাফলের একটি আকৃতি থাকে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই ভেরিয়েন্টে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে ক্রিয়াকলাপগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির একটি একটি স্কেলার হয়।

বিভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক বিদ্যমান এবং এর জন্য:

And(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে
rhs XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে
সম্প্রচার_মাত্রা ArraySlice লক্ষ্য আকৃতির কোন মাত্রা অপারেন্ড আকৃতির প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিকটি বিভিন্ন র‌্যাঙ্কের অ্যারের মধ্যে গাণিতিক ক্রিয়াকলাপের জন্য ব্যবহার করা উচিত (যেমন একটি ভেক্টরে একটি ম্যাট্রিক্স যোগ করা)।

অতিরিক্ত ব্রডকাস্ট_ডাইমেনশন অপারেন্ড হল পূর্ণসংখ্যার একটি স্লাইস যা অপারেন্ড সম্প্রচারের জন্য ব্যবহার করার মাত্রা নির্দিষ্ট করে। শব্দার্থবিদ্যা সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

StableHLO তথ্যের জন্য StableHLO - এবং দেখুন।

অ্যাসিঙ্ক

আরও দেখুন HloInstruction::CreateAsyncStart , HloInstruction::CreateAsyncUpdate , HloInstruction::CreateAsyncDone

AsyncDone , AsyncStart , এবং AsyncUpdate হল অভ্যন্তরীণ HLO নির্দেশাবলী অ্যাসিঙ্ক্রোনাস ক্রিয়াকলাপের জন্য ব্যবহৃত হয় এবং HLO-তে আদিম হিসাবে কাজ করে৷ এই অপ্সগুলি HLO ডাম্পগুলিতে প্রদর্শিত হতে পারে তবে সেগুলি শেষ ব্যবহারকারীদের দ্বারা ম্যানুয়ালি তৈরি করার উদ্দেশ্যে নয়৷

Atan2

এছাড়াও দেখুন XlaBuilder::Atan2

lhs এবং rhs এ উপাদান-ভিত্তিক atan2 অপারেশন সম্পাদন করে।

Atan2(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে
rhs XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে

আর্গুমেন্টের আকারগুলি একই রকম বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী সে সম্পর্কে সম্প্রচার ডকুমেন্টেশন দেখুন৷ একটি অপারেশনের ফলাফলের একটি আকৃতি থাকে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই ভেরিয়েন্টে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে ক্রিয়াকলাপগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির একটি একটি স্কেলার হয়।

Atan2 এর জন্য ভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক বিদ্যমান:

Atan2(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে
rhs XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে
সম্প্রচার_মাত্রা ArraySlice লক্ষ্য আকৃতির কোন মাত্রা অপারেন্ড আকৃতির প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিকটি বিভিন্ন র‌্যাঙ্কের অ্যারের মধ্যে গাণিতিক ক্রিয়াকলাপের জন্য ব্যবহার করা উচিত (যেমন একটি ভেক্টরে একটি ম্যাট্রিক্স যোগ করা)।

অতিরিক্ত ব্রডকাস্ট_ডাইমেনশন অপারেন্ড হল পূর্ণসংখ্যার একটি স্লাইস যা অপারেন্ড সম্প্রচারের জন্য ব্যবহার করার মাত্রা নির্দিষ্ট করে। শব্দার্থবিদ্যা সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

StableHLO তথ্যের জন্য StableHLO - atan2 দেখুন।

ব্যাচ নর্মগ্র্যাড

অ্যালগরিদমের বিশদ বিবরণের জন্য XlaBuilder::BatchNormGrad এবং মূল ব্যাচের স্বাভাবিককরণের কাগজটিও দেখুন।

ব্যাচের আদর্শের গ্রেডিয়েন্ট গণনা করে।

BatchNormGrad(operand, scale, batch_mean, batch_var, grad_output, epsilon, feature_index)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp n মাত্রিক বিন্যাস স্বাভাবিক করা হবে (x)
scale XlaOp 1 মাত্রিক অ্যারে (\(\gamma\))
batch_mean XlaOp 1 মাত্রিক অ্যারে (\(\mu\))
batch_var XlaOp 1 মাত্রিক অ্যারে (\(\sigma^2\))
grad_output XlaOp গ্রেডিয়েন্ট BatchNormTraining -এ পাস করা হয়েছে (\(\nabla y\))
epsilon float এপসিলন মান (\(\epsilon\))
feature_index int64 operand বৈশিষ্ট্যের মাত্রার সূচক

ফিচার ডাইমেনশনের প্রতিটি ফিচারের জন্য ( feature_index হল operand ফিচার ডাইমেনশনের জন্য সূচক), অপারেশনটি অন্য সব ডাইমেনশন জুড়ে operand , offset এবং scale সাপেক্ষে গ্রেডিয়েন্ট গণনা করে। feature_index operand বৈশিষ্ট্যের মাত্রার জন্য একটি বৈধ সূচক হতে হবে।

তিনটি গ্রেডিয়েন্ট নিম্নলিখিত সূত্র দ্বারা সংজ্ঞায়িত করা হয়েছে ( operand হিসাবে একটি 4-মাত্রিক অ্যারে ধরে নেওয়া এবং বৈশিষ্ট্যের মাত্রা সূচক l , ব্যাচের আকার m এবং স্থানিক আকার w এবং h সহ):

\[ \begin{split} c_l&= \frac{1}{mwh}\sum_{i=1}^m\sum_{j=1}^w\sum_{k=1}^h \left( \nabla y_{ijkl} \frac{x_{ijkl} - \mu_l}{\sigma^2_l+\epsilon} \right) \\\\ d_l&= \frac{1}{mwh}\sum_{i=1}^m\sum_{j=1}^w\sum_{k=1}^h \nabla y_{ijkl} \\\\ \nabla x_{ijkl} &= \frac{\gamma_{l} }{\sqrt{\sigma^2_{l}+\epsilon} } \left( \nabla y_{ijkl} - d_l - c_l (x_{ijkl} - \mu_{l}) \right) \\\\ \nabla \gamma_l &= \sum_{i=1}^m\sum_{j=1}^w\sum_{k=1}^h \left( \nabla y_{ijkl} \frac{x_{ijkl} - \mu_l}{\sqrt{\sigma^2_{l}+\epsilon} } \right) \\\\\ \nabla \beta_l &= \sum_{i=1}^m\sum_{j=1}^w\sum_{k=1}^h \nabla y_{ijkl} \end{split} \]

ইনপুট batch_mean এবং batch_var ব্যাচ এবং স্থানিক মাত্রা জুড়ে মুহূর্ত মান উপস্থাপন করে।

আউটপুট প্রকারটি তিনটি হ্যান্ডেলের একটি টিপল:

আউটপুট টাইপ শব্দার্থবিদ্যা
grad_operand XlaOp ইনপুট operand সাথে গ্রেডিয়েন্ট (\(\nabla x\))
grad_scale XlaOp ইনপুট ** scale ** (\(\nabla\gamma\))
grad_offset XlaOp ইনপুট offset ক্ষেত্রে গ্রেডিয়েন্ট (\(\nabla\beta\))

StableHLO তথ্যের জন্য StableHLO - batch_norm_grad দেখুন।

BatchNormInference

অ্যালগরিদমের বিশদ বিবরণের জন্য XlaBuilder::BatchNormInference এবং মূল ব্যাচের স্বাভাবিককরণ কাগজটিও দেখুন।

ব্যাচ এবং স্থানিক মাত্রা জুড়ে একটি অ্যারেকে স্বাভাবিক করে।

BatchNormInference(operand, scale, offset, mean, variance, epsilon, feature_index)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp n ডাইমেনশনাল অ্যারেকে স্বাভাবিক করতে হবে
scale XlaOp 1 মাত্রিক অ্যারে
offset XlaOp 1 মাত্রিক অ্যারে
mean XlaOp 1 মাত্রিক অ্যারে
variance XlaOp 1 মাত্রিক অ্যারে
epsilon float এপসিলন মান
feature_index int64 operand বৈশিষ্ট্যের মাত্রার সূচক

ফিচার ডাইমেনশনের প্রতিটি ফিচারের জন্য ( feature_index হল operand ফিচার ডাইমেনশনের জন্য সূচক), অপারেশনটি অন্য সব ডাইমেনশন জুড়ে গড় এবং ভ্যারিয়েন্স গণনা করে এবং operand প্রতিটি উপাদানকে স্বাভাবিক করার জন্য গড় এবং প্রকরণ ব্যবহার করে। feature_index operand বৈশিষ্ট্যের মাত্রার জন্য একটি বৈধ সূচক হতে হবে।

BatchNormInference প্রতিটি ব্যাচের mean এবং variance গণনা না করে BatchNormTraining কল করার সমতুল্য। এটি আনুমানিক মান হিসাবে পরিবর্তে ইনপুট mean এবং variance ব্যবহার করে। এই অপের উদ্দেশ্য হল অনুমানে বিলম্ব কমানো, তাই নাম BatchNormInference

আউটপুট হল একটি এন-ডাইমেনশনাল, ইনপুট operand মতো একই আকৃতি সহ স্বাভাবিক বিন্যাস।

StableHLO তথ্যের জন্য StableHLO - batch_norm_inference দেখুন।

ব্যাচ নর্ম ট্রেনিং

অ্যালগরিদমের বিশদ বিবরণের জন্য XlaBuilder::BatchNormTraining এবং the original batch normalization paper দেখুন।

ব্যাচ এবং স্থানিক মাত্রা জুড়ে একটি অ্যারেকে স্বাভাবিক করে।

BatchNormTraining(operand, scale, offset, epsilon, feature_index)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp n মাত্রিক বিন্যাস স্বাভাবিক করা হবে (x)
scale XlaOp 1 মাত্রিক অ্যারে (\(\gamma\))
offset XlaOp 1 মাত্রিক অ্যারে (\(\beta\))
epsilon float এপসিলন মান (\(\epsilon\))
feature_index int64 operand বৈশিষ্ট্যের মাত্রার সূচক

ফিচার ডাইমেনশনের প্রতিটি ফিচারের জন্য ( feature_index হল operand ফিচার ডাইমেনশনের জন্য সূচক), অপারেশনটি অন্য সব ডাইমেনশন জুড়ে গড় এবং ভ্যারিয়েন্স গণনা করে এবং operand প্রতিটি উপাদানকে স্বাভাবিক করার জন্য গড় এবং প্রকরণ ব্যবহার করে। feature_index operand বৈশিষ্ট্যের মাত্রার জন্য একটি বৈধ সূচক হতে হবে।

operand প্রতিটি ব্যাচের জন্য অ্যালগরিদমটি নিম্নরূপ \(x\) যেখানে স্থানিক মাত্রার আকার হিসাবে w এবং h সহ m উপাদান রয়েছে ( operand একটি 4 মাত্রিক অ্যারে ধরে নেওয়া হচ্ছে):

  • ব্যাচ গড় গণনা করে \(\mu_l\) প্রতিটি বৈশিষ্ট্যের জন্য l বৈশিষ্ট্য মাত্রায়:\(\mu_l=\frac{1}{mwh}\sum_{i=1}^m\sum_{j=1}^w\sum_{k=1}^h x_{ijkl}\)

  • ব্যাচ বৈচিত্র্য গণনা করে \(\sigma^2_l\): $\sigma^2 l=\frac{1}{mwh}\sum {i=1}^m\sum {j=1}^w\sum {k=1}^h (x_{ijkl} - \mu_l)^2$

  • স্বাভাবিককরণ, স্কেল এবং পরিবর্তন:\(y_{ijkl}=\frac{\gamma_l(x_{ijkl}-\mu_l)}{\sqrt[2]{\sigma^2_l+\epsilon} }+\beta_l\)

এপসিলন মান, সাধারণত একটি ছোট সংখ্যা, বিভাজন-দ্বারা-শূন্য ত্রুটি এড়াতে যোগ করা হয়।

আউটপুট টাইপ তিনটি XlaOp s এর একটি টিপল:

আউটপুট টাইপ শব্দার্থবিদ্যা
output XlaOp ইনপুট operand (y) এর মতো একই আকার সহ n মাত্রিক বিন্যাস
batch_mean XlaOp 1 মাত্রিক অ্যারে (\(\mu\))
batch_var XlaOp 1 মাত্রিক অ্যারে (\(\sigma^2\))

batch_mean এবং batch_var হল উপরের সূত্রগুলি ব্যবহার করে ব্যাচ এবং স্থানিক মাত্রা জুড়ে গণনা করা মুহূর্ত।

StableHLO তথ্যের জন্য StableHLO - batch_norm_training দেখুন।

বিটকাস্ট

আরও দেখুন HloInstruction::CreateBitcast

Bitcast এইচএলও ডাম্পে প্রদর্শিত হতে পারে, তবে সেগুলি শেষ ব্যবহারকারীদের দ্বারা ম্যানুয়ালি তৈরি করার উদ্দেশ্যে নয়।

BitcastConvertType

আরও দেখুন XlaBuilder::BitcastConvertType

TensorFlow-এর একটি tf.bitcast এর মতোই, ডেটা শেপ থেকে টার্গেট শেপে এলিমেন্ট-ভিত্তিক বিটকাস্ট অপারেশন করে। ইনপুট এবং আউটপুট আকার অবশ্যই মিলবে: যেমন s32 উপাদানগুলি বিটকাস্ট রুটিনের মাধ্যমে f32 উপাদানে পরিণত হবে এবং একটি s32 উপাদান চারটি s8 উপাদানে পরিণত হবে৷ বিটকাস্ট একটি নিম্ন-স্তরের কাস্ট হিসাবে প্রয়োগ করা হয়, তাই বিভিন্ন ফ্লোটিং-পয়েন্ট উপস্থাপনা সহ মেশিনগুলি বিভিন্ন ফলাফল দেবে।

BitcastConvertType(operand, new_element_type)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ডিমস ডি সহ T টাইপের অ্যারে
new_element_type PrimitiveType U টাইপ করুন

অপারেন্ডের মাত্রা এবং লক্ষ্য আকৃতি অবশ্যই মিলতে হবে, শেষ মাত্রা ছাড়াও যা রূপান্তরের আগে এবং পরে আদিম আকারের অনুপাত দ্বারা পরিবর্তিত হবে।

উত্স এবং গন্তব্য উপাদানের প্রকারগুলি অবশ্যই টিপল হতে হবে না৷

StableHLO তথ্যের জন্য StableHLO - bitcast_convert দেখুন।

বিটকাস্ট-বিভিন্ন প্রস্থের আদিম প্রকারে রূপান্তর

BitcastConvert HLO নির্দেশটি সেই ক্ষেত্রে সমর্থন করে যেখানে আউটপুট উপাদানের আকার T' ইনপুট উপাদান T এর আকারের সমান নয়। যেহেতু পুরো অপারেশনটি ধারণাগতভাবে একটি বিটকাস্ট এবং অন্তর্নিহিত বাইট পরিবর্তন করে না, আউটপুট উপাদানটির আকৃতি পরিবর্তন করতে হবে। B = sizeof(T), B' = sizeof(T') , দুটি সম্ভাব্য ক্ষেত্রে আছে।

প্রথমত, যখন B > B' , আউটপুট আকারটি B/B' আকারের একটি নতুন ক্ষুদ্র-সবচেয়ে মাত্রা পায়। যেমন:

  f16[10,2]{1,0} %output = f16[10,2]{1,0} bitcast-convert(f32[10]{0} %input)

কার্যকর স্কেলারের জন্য নিয়ম একই থাকে:

  f16[2]{0} %output = f16[2]{0} bitcast-convert(f32[] %input)

বিকল্পভাবে, B' > B জন্য নির্দেশের জন্য ইনপুট আকারের শেষ লজিক্যাল মাত্রাটি B'/B এর সমান হওয়া প্রয়োজন, এবং এই মাত্রাটি রূপান্তরের সময় বাদ দেওয়া হয়:

  f32[10]{0} %output = f32[10]{0} bitcast-convert(f16[10,2]{1,0} %input)

মনে রাখবেন যে বিভিন্ন বিটউইথের মধ্যে রূপান্তরগুলি উপাদান অনুসারে নয়।

সম্প্রচার

এছাড়াও দেখুন XlaBuilder::Broadcast .

অ্যারেতে ডেটা সদৃশ করে একটি অ্যারেতে মাত্রা যোগ করে।

Broadcast(operand, broadcast_sizes)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ডুপ্লিকেট করার জন্য অ্যারে
broadcast_sizes ArraySlice<int64> নতুন মাত্রার মাপ

নতুন মাত্রা বাম দিকে সন্নিবেশ করা হয়েছে, অর্থাৎ যদি broadcast_sizes মান থাকে {a0, ..., aN} এবং অপারেন্ড আকারের মাত্রা থাকে {b0, ..., bM} তাহলে আউটপুটের আকারের মাত্রা আছে {a0, ..., aN, b0, ..., bM}

অপারেন্ডের অনুলিপিতে নতুন মাত্রা সূচক, অর্থাৎ

output[i0, ..., iN, j0, ..., jM] = operand[j0, ..., jM]

উদাহরণস্বরূপ, যদি operand 2.0f মান সহ একটি স্কেলার f32 হয় এবং broadcast_sizes হয় {2, 3} , তাহলে ফলাফলটি আকার f32[2, 3] সহ একটি অ্যারে হবে এবং ফলাফলের সমস্ত মান 2.0f হবে।

StableHLO তথ্যের জন্য StableHLO - সম্প্রচার দেখুন।

ব্রডকাস্ট ইনডিম

এছাড়াও দেখুন XlaBuilder::BroadcastInDim

অ্যারেতে ডেটা সদৃশ করে একটি অ্যারের আকার এবং মাত্রার সংখ্যা প্রসারিত করে।

BroadcastInDim(operand, out_dim_size, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ডুপ্লিকেট করার জন্য অ্যারে
out_dim_size ArraySlice<int64> লক্ষ্য আকৃতির মাত্রার মাপ
broadcast_dimensions ArraySlice<int64> লক্ষ্য আকৃতির কোন মাত্রা অপারেন্ড আকৃতির প্রতিটি মাত্রার সাথে মিলে যায়

সম্প্রচারের অনুরূপ, কিন্তু যে কোনো জায়গায় মাত্রা যোগ করতে এবং 1 আকারের সাথে বিদ্যমান মাত্রা প্রসারিত করার অনুমতি দেয়।

operand out_dim_size দ্বারা বর্ণিত আকারে সম্প্রচার করা হয়। broadcast_dimensions operand ডাইমেনশনকে টার্গেট আকৃতির ডাইমেনশনে ম্যাপ করে, অর্থাৎ অপারেন্ডের i'th ডাইমেনশন আউটপুট শেপের ব্রডকাস্ট_ডাইমেনশন[i]'ম ডাইমেনশনে ম্যাপ করা হয়। operand ডাইমেনশনের সাইজ 1 থাকতে হবে অথবা আউটপুট আকৃতিতে যে ডাইমেনশনে ম্যাপ করা হয়েছে সেই আকারের সমান হতে হবে। অবশিষ্ট মাত্রাগুলি 1 আকারের মাত্রা দিয়ে পূর্ণ। ডিজেনারেট-ডাইমেনশন সম্প্রচার তারপর আউটপুট আকারে পৌঁছানোর জন্য এই অধঃপতন মাত্রাগুলি বরাবর সম্প্রচার করে। শব্দার্থবিদ্যা সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

কল

এছাড়াও দেখুন XlaBuilder::Call

প্রদত্ত আর্গুমেন্টের সাথে একটি গণনা আহ্বান করে।

Call(computation, operands...)

যুক্তি টাইপ শব্দার্থবিদ্যা
computation XlaComputation T_0, T_1, ..., T_{N-1} -> S প্রকারের নির্বিচারে টাইপের N প্যারামিটার সহ গণনা
operands N XlaOp s এর ক্রম স্বেচ্ছাচারী প্রকারের এন আর্গুমেন্ট

operands আরিটি এবং প্রকারগুলি অবশ্যই computation পরামিতিগুলির সাথে মেলে। এটা কোন operands আছে অনুমোদিত হয়.

কম্পোজিটকল

এছাড়াও দেখুন XlaBuilder::CompositeCall

অন্যান্য StableHLO ক্রিয়াকলাপগুলির সমন্বয়ে গঠিত (রচিত) একটি অপারেশনকে এনক্যাপসুলেট করে, ইনপুট এবং যৌগিক_ বৈশিষ্ট্য গ্রহণ করে এবং ফলাফল তৈরি করে। অপের শব্দার্থবিদ্যা পচন বৈশিষ্ট্য দ্বারা বাস্তবায়িত হয়। যৌগিক অপটি প্রোগ্রাম শব্দার্থবিদ্যা পরিবর্তন না করে তার পচন দিয়ে প্রতিস্থাপিত করা যেতে পারে। যে ক্ষেত্রে ইনলাইন পচন একই বিকল্প শব্দার্থ প্রদান করে না, custom_call ব্যবহার করতে পছন্দ করুন।

সংস্করণ ক্ষেত্রটি (ডিফল্ট 0 থেকে) বোঝাতে ব্যবহৃত হয় যখন একটি যৌগিক শব্দার্থ পরিবর্তন হয়।

এই অপশনটি is_composite=true বৈশিষ্ট্য সহ একটি kCall হিসাবে প্রয়োগ করা হয়েছে। decomposition ক্ষেত্র computation বৈশিষ্ট্য দ্বারা নির্দিষ্ট করা হয়. ফ্রন্টএন্ড অ্যাট্রিবিউটগুলি composite. .

CompositeCall op উদাহরণ:

f32[] call(f32[] %cst), to_apply=%computation, is_composite=true,
frontend_attributes = {
  composite.name="foo.bar",
  composite.attributes={n = 1 : i32, tensor = dense<1> : tensor<i32>},
  composite.version="1"
}

CompositeCall(computation, operands..., name, attributes, version)

যুক্তি টাইপ শব্দার্থবিদ্যা
computation XlaComputation T_0, T_1, ..., T_{N-1} -> S প্রকারের নির্বিচারে টাইপের N প্যারামিটার সহ গণনা
operands N XlaOp s এর ক্রম মানের বৈচিত্র্যিক সংখ্যা
name string কম্পোজিট এর নাম
attributes ঐচ্ছিক string বৈশিষ্ট্যের ঐচ্ছিক স্ট্রিংফাইড অভিধান
version ঐচ্ছিক int64 কম্পোজিট অপের শব্দার্থবিদ্যায় সংখ্যা থেকে সংস্করণ আপডেট

একটি অপের decomposition একটি ক্ষেত্র বলা হয় না, কিন্তু পরিবর্তে একটি to_apply বৈশিষ্ট্য হিসাবে প্রদর্শিত হয় যা নিম্ন-স্তরের বাস্তবায়ন ধারণ করে এমন ফাংশনকে নির্দেশ করে, যেমন to_apply=%funcname

কম্পোজিট এবং পচন সম্পর্কিত আরও তথ্য StableHLO স্পেসিফিকেশনে পাওয়া যাবে।

সিবিআরটি

আরও দেখুন XlaBuilder::Cbrt

এলিমেন্ট-ভিত্তিক কিউবিক রুট অপারেশন x -> cbrt(x)

Cbrt(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ফাংশনের অপারেন্ড

Cbrt ঐচ্ছিক result_accuracy যুক্তি সমর্থন করে:

Cbrt(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ফাংশনের অপারেন্ড
result_accuracy ঐচ্ছিক ResultAccuracy ব্যবহারকারী একাধিক বাস্তবায়নের সাথে unary ops এর জন্য যে ধরনের নির্ভুলতার অনুরোধ করতে পারে

result_accuracy সম্পর্কে আরও তথ্যের জন্য ফলাফলের সঠিকতা দেখুন।

StableHLO তথ্যের জন্য StableHLO - cbrt দেখুন।

সিল

এছাড়াও দেখুন XlaBuilder::Ceil

উপাদান-ভিত্তিক সিল x -> ⌈x⌉

Ceil(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ফাংশনের অপারেন্ড

StableHLO তথ্যের জন্য StableHLO - ceil দেখুন।

চোলেস্কি

XlaBuilder::Cholesky আরও দেখুন।

সিমেট্রিক (হার্মিটিয়ান) ধনাত্মক নির্দিষ্ট ম্যাট্রিক্সের একটি ব্যাচের চোলেস্কি পচন গণনা করে।

Cholesky(a, lower)

যুক্তি টাইপ শব্দার্থবিদ্যা
a XlaOp > 2 মাত্রা সহ একটি জটিল বা ভাসমান-বিন্দু টাইপের একটি অ্যারে।
lower bool a এর উপরের বা নীচের ত্রিভুজ ব্যবহার করবেন কিনা।

lower true হলে, নিম্ন-ত্রিভুজাকার ম্যাট্রিক্স l গণনা করে যেমন $a = l। l^T$। lower যদি false হয়, ঊর্ধ্ব-ত্রিভুজাকার ম্যাট্রিক্স গণনা করে u যেমন\(a = u^T . u\).

ইনপুট ডেটা কেবলমাত্র a এর নিম্ন/উপরের ত্রিভুজ থেকে পড়া হয়, lower মানের উপর নির্ভর করে। অন্য ত্রিভুজ থেকে মান উপেক্ষা করা হয়. আউটপুট ডেটা একই ত্রিভুজে ফেরত দেওয়া হয়; অন্য ত্রিভুজের মানগুলি বাস্তবায়ন-সংজ্ঞায়িত এবং কিছু হতে পারে।

যদি a 2টির বেশি মাত্রা থাকে, তাহলে a ম্যাট্রিক্সের একটি ব্যাচ হিসাবে গণ্য করা হয়, যেখানে ছোট 2টি মাত্রা ছাড়া বাকি সবগুলিই ব্যাচের মাত্রা।

যদি a প্রতিসম (Hermitian) ধনাত্মক নির্দিষ্ট না হয়, ফলাফলটি বাস্তবায়ন-সংজ্ঞায়িত হয়।

StableHLO তথ্যের জন্য StableHLO - cholesky দেখুন।

বাতা

এছাড়াও দেখুন XlaBuilder::Clamp

ন্যূনতম এবং সর্বোচ্চ মানের মধ্যে একটি অপারেন্ডকে ক্ল্যাম্প করে।

Clamp(min, operand, max)

যুক্তি টাইপ শব্দার্থবিদ্যা
min XlaOp T টাইপের অ্যারে
operand XlaOp T টাইপের অ্যারে
max XlaOp T টাইপের অ্যারে

একটি অপারেন্ড এবং ন্যূনতম এবং সর্বোচ্চ মান দেওয়া হলে, অপারেন্ডটি ন্যূনতম এবং সর্বোচ্চের মধ্যে থাকলে তা ফেরত দেয়, অন্যথায় অপারেন্ডটি এই সীমার নীচে হলে সর্বনিম্ন মান বা অপারেন্ডটি এই সীমার উপরে থাকলে সর্বোচ্চ মান প্রদান করে। অর্থাৎ, clamp(a, x, b) = min(max(a, x), b)

তিনটি অ্যারে একই আকৃতির হতে হবে। বিকল্পভাবে, সম্প্রচারের একটি সীমাবদ্ধ রূপ হিসাবে, min এবং/অথবা max T টাইপের স্কেলার হতে পারে।

স্কেলার min এবং max সহ উদাহরণ:

let operand: s32[3] = {-1, 5, 9};
let min: s32 = 0;
let max: s32 = 6;
==>
Clamp(min, operand, max) = s32[3]{0, 5, 6};

StableHLO তথ্যের জন্য StableHLO - clamp দেখুন।

সঙ্কুচিত

XlaBuilder::Collapse আরও দেখুন। এবং tf.reshape অপারেশন।

একটি অ্যারের মাত্রাগুলিকে একটি মাত্রায় সঙ্কুচিত করে৷

Collapse(operand, dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp T টাইপের অ্যারে
dimensions int64 ভেক্টর ইন-অর্ডার, T-এর মাত্রার পরপর উপসেট।

সঙ্কুচিত একটি একক মাত্রা দ্বারা অপারেন্ডের মাত্রার প্রদত্ত উপসেট প্রতিস্থাপন করে। ইনপুট আর্গুমেন্ট হল T টাইপের একটি নির্বিচারে অ্যারে এবং মাত্রা সূচকগুলির একটি কম্পাইল-টাইম-কনস্ট্যান্ট ভেক্টর। মাত্রা সূচকগুলি অবশ্যই একটি ইন-অর্ডার হতে হবে (নিম্ন থেকে উচ্চ মাত্রার সংখ্যা), T-এর মাত্রার ধারাবাহিক উপসেট। এইভাবে, {0, 1, 2}, {0, 1}, বা {1, 2} সবই বৈধ মাত্রা সেট, কিন্তু {1, 0} বা {0, 2} নয়৷ এগুলিকে একটি একক নতুন মাত্রা দ্বারা প্রতিস্থাপিত করা হয়, তারা যেগুলি প্রতিস্থাপন করে সেই মাত্রার ক্রমানুসারে একই অবস্থানে, নতুন মাত্রার আকার মূল মাত্রার মাপের গুণফলের সমান। dimensions মধ্যে সর্বনিম্ন মাত্রা সংখ্যা হল লুপ নেস্টে সবচেয়ে ধীর পরিবর্তিত মাত্রা (সবচেয়ে বড়) যা এই মাত্রাগুলিকে ভেঙে দেয় এবং সর্বোচ্চ মাত্রা সংখ্যাটি দ্রুততম পরিবর্তিত (সবচেয়ে ছোট)। আরও সাধারণ পতনের ক্রম প্রয়োজন হলে tf.reshape অপারেটর দেখুন।

উদাহরণস্বরূপ, v 24 টি উপাদানের একটি অ্যারে হতে দিন:

let v = f32[4x2x3] { { {10, 11, 12}, {15, 16, 17} },
{ {20, 21, 22}, {25, 26, 27} },
{ {30, 31, 32}, {35, 36, 37} },
{ {40, 41, 42}, {45, 46, 47} } };

// Collapse to a single dimension, leaving one dimension.
let v012 = Collapse(v, {0,1,2});
then v012 == f32[24] {10, 11, 12, 15, 16, 17,
20, 21, 22, 25, 26, 27,
30, 31, 32, 35, 36, 37,
40, 41, 42, 45, 46, 47};

// Collapse the two lower dimensions, leaving two dimensions.
let v01 = Collapse(v, {0,1});
then v01 == f32[4x6] { {10, 11, 12, 15, 16, 17},
{20, 21, 22, 25, 26, 27},
{30, 31, 32, 35, 36, 37},
{40, 41, 42, 45, 46, 47} };

// Collapse the two higher dimensions, leaving two dimensions.
let v12 = Collapse(v, {1,2});
then v12 == f32[8x3] { {10, 11, 12},
{15, 16, 17},
{20, 21, 22},
{25, 26, 27},
{30, 31, 32},
{35, 36, 37},
{40, 41, 42},
{45, 46, 47} };

Clz

আরও দেখুন XlaBuilder::Clz

উপাদান-ভিত্তিক গণনা অগ্রণী শূন্য।

Clz(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ফাংশনের অপারেন্ড

যৌথ সম্প্রচার

এছাড়াও দেখুন XlaBuilder::CollectiveBroadcast .

প্রতিলিপি জুড়ে ডেটা সম্প্রচার করে। প্রতিটি গ্রুপের প্রথম রেপ্লিকা আইডি থেকে একই গ্রুপের অন্যান্য আইডিতে ডেটা পাঠানো হয়। যদি একটি প্রতিলিপি আইডি কোনো প্রতিলিপি গ্রুপে না থাকে, তাহলে সেই প্রতিরূপের আউটপুটটি 0(গুলি) shape নিয়ে গঠিত একটি টেনসর।

CollectiveBroadcast(operand, replica_groups, channel_id)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ফাংশনের অপারেন্ড
replica_groups ReplicaGroup ভেক্টর প্রতিটি গ্রুপে প্রতিলিপি আইডিগুলির একটি তালিকা রয়েছে৷
channel_id ঐচ্ছিক ChannelHandle প্রতিটি পাঠান/recv জোড়ার জন্য অনন্য শনাক্তকারী

StableHLO তথ্যের জন্য StableHLO - সম্মিলিত_সম্প্রচার দেখুন।

কালেক্টিভ পারমিউট

এছাড়াও দেখুন XlaBuilder::CollectivePermute .

CollectivePermute হল একটি যৌথ অপারেশন যা প্রতিলিপি জুড়ে ডেটা পাঠায় এবং গ্রহণ করে।

CollectivePermute(operand, source_target_pairs, channel_id, inplace)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp n মাত্রিক ইনপুট অ্যারে
source_target_pairs <int64, int64> ভেক্টর (source_replica_id, target_replica_id) জোড়ার একটি তালিকা। প্রতিটি জোড়ার জন্য, অপারেন্ডটি উৎস প্রতিলিপি থেকে লক্ষ্য প্রতিলিপিতে পাঠানো হয়।
channel_id ঐচ্ছিক ChannelHandle ক্রস-মডিউল যোগাযোগের জন্য ঐচ্ছিক চ্যানেল আইডি
inpace ঐচ্ছিক bool স্থানান্তর করা উচিত কিনা তা পতাকাঙ্কিত করুন

মনে রাখবেন source_target_pairs নিম্নলিখিত সীমাবদ্ধতা রয়েছে:

  • যেকোনো দুই জোড়ার একই টার্গেট রেপ্লিকা আইডি থাকা উচিত নয় এবং তাদের একই সোর্স রেপ্লিকা আইডি থাকা উচিত নয়।
  • যদি একটি প্রতিলিপি আইডি কোনো জোড়ায় লক্ষ্য না হয়, তাহলে সেই প্রতিরূপের আউটপুটটি ইনপুটের মতো একই আকৃতি সহ 0(গুলি) সমন্বিত একটি টেনসর।

CollectivePermute অপারেশনের API অভ্যন্তরীণভাবে 2টি HLO নির্দেশাবলীতে পচে যায় ( CollectivePermuteStart এবং CollectivePermuteDone )।

আরও দেখুন HloInstruction::CreateCollectivePermuteStart

CollectivePermuteStart এবং CollectivePermuteDone HLO-তে আদিম হিসেবে কাজ করে। এই অপ্সগুলি HLO ডাম্পগুলিতে প্রদর্শিত হতে পারে, তবে এগুলি শেষ ব্যবহারকারীদের দ্বারা ম্যানুয়ালি তৈরি করার উদ্দেশ্যে নয়।

StableHLO তথ্যের জন্য StableHLO - collective_permute দেখুন।

তুলনা করুন

এছাড়াও দেখুন XlaBuilder::Compare

নিম্নলিখিতগুলির lhs এবং rhs এর উপাদান-ভিত্তিক তুলনা সম্পাদন করে:

সমক

আরও দেখুন XlaBuilder::Eq

lhs এবং rhs এর তুলনা করার জন্য উপাদান-ভিত্তিক সমান- সঞ্চালন করে।

\(lhs = rhs\)

Eq(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে
rhs XlaOp বাম-হাত-সাইড অপারেন্ড: T টাইপের অ্যারে

আর্গুমেন্টের আকারগুলি একই রকম বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী তা সম্পর্কে সম্প্রচারের ডকুমেন্টেশন দেখুন। অপারেশনের ফলাফলের একটি আকার রয়েছে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই বৈকল্পিকভাবে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে অপারেশনগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির মধ্যে একটি স্কেলার হয়।

বিভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক EQ এর জন্য বিদ্যমান:

Eq(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিক বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে গাণিতিক ক্রিয়াকলাপগুলির জন্য ব্যবহার করা উচিত (যেমন কোনও ভেক্টরে ম্যাট্রিক্স যুক্ত করা)।

অতিরিক্ত সম্প্রচার_ডিমেনশনস অপারেন্ড হ'ল অপারেশনগুলি সম্প্রচারের জন্য ব্যবহারের জন্য মাত্রাগুলি নির্দিষ্ট করে এমন পূর্ণসংখ্যার একটি টুকরো। শব্দার্থবিজ্ঞানগুলি সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

কার্যকরভাবে কার্যকর করে ভাসমান পয়েন্ট নম্বরগুলির উপর মোট অর্ডার সমর্থন করুন:

\[-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN.\]

EqTotalOrder(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - তুলনা করুন

নে

XlaBuilder::Ne দেখুন।

lhs এবং rhs তুলনা সমান নয় এমন উপাদান অনুসারে সম্পাদন করে।

\(lhs != rhs\)

Ne(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে

যুক্তিগুলির আকারগুলি হয় একই বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী তা সম্পর্কে সম্প্রচারের ডকুমেন্টেশন দেখুন। অপারেশনের ফলাফলের একটি আকার রয়েছে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই বৈকল্পিকভাবে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে অপারেশনগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির মধ্যে একটি স্কেলার হয়।

বিভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক NE এর জন্য বিদ্যমান:

Ne(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিক বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে গাণিতিক ক্রিয়াকলাপগুলির জন্য ব্যবহার করা উচিত (যেমন কোনও ভেক্টরে ম্যাট্রিক্স যুক্ত করা)।

অতিরিক্ত সম্প্রচার_ডিমেনশনস অপারেন্ড হ'ল অপারেশনগুলি সম্প্রচারের জন্য ব্যবহারের জন্য মাত্রাগুলি নির্দিষ্ট করে এমন পূর্ণসংখ্যার একটি টুকরো। শব্দার্থবিজ্ঞানগুলি সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

কার্যকরভাবে কার্যকর করে ভাসমান পয়েন্ট নম্বরগুলির উপর মোট অর্ডার সমর্থন করুন:

\[-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN.\]

NeTotalOrder(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - তুলনা করুন

জি

XlaBuilder::Ge দেখুন।

lhs এবং rhs তুলনায় উপাদান-ভিত্তিক বৃহত্তর-বা-সমান-তুলনা সম্পাদন করে।

\(lhs >= rhs\)

Ge(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে

যুক্তিগুলির আকারগুলি হয় একই বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী তা সম্পর্কে সম্প্রচারের ডকুমেন্টেশন দেখুন। অপারেশনের ফলাফলের একটি আকার রয়েছে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই বৈকল্পিকভাবে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে অপারেশনগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির মধ্যে একটি স্কেলার হয়।

বিভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক জিই এর জন্য বিদ্যমান:

Ge(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিক বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে গাণিতিক ক্রিয়াকলাপগুলির জন্য ব্যবহার করা উচিত (যেমন কোনও ভেক্টরে ম্যাট্রিক্স যুক্ত করা)।

অতিরিক্ত সম্প্রচার_ডিমেনশনস অপারেন্ড হ'ল অপারেশনগুলি সম্প্রচারের জন্য ব্যবহারের জন্য মাত্রাগুলি নির্দিষ্ট করে এমন পূর্ণসংখ্যার একটি টুকরো। শব্দার্থবিজ্ঞানগুলি সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

কার্যকর করে জিটি -র জন্য ভাসমান পয়েন্ট নম্বরগুলির উপর মোট অর্ডার সমর্থন করুন:

\[-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN.\]

GtTotalOrder(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - তুলনা করুন

জিটি

XlaBuilder::Gt দেখুন।

lhs এবং rhs তুলনায় উপাদান-ভিত্তিক বৃহত্তর-তুলনা সম্পাদন করে।

\(lhs > rhs\)

Gt(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে

যুক্তিগুলির আকারগুলি হয় একই বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী তা সম্পর্কে সম্প্রচারের ডকুমেন্টেশন দেখুন। অপারেশনের ফলাফলের একটি আকার রয়েছে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই বৈকল্পিকভাবে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে অপারেশনগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির মধ্যে একটি স্কেলার হয়।

বিভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক জিটি-র জন্য বিদ্যমান:

Gt(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিক বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে গাণিতিক ক্রিয়াকলাপগুলির জন্য ব্যবহার করা উচিত (যেমন কোনও ভেক্টরে ম্যাট্রিক্স যুক্ত করা)।

অতিরিক্ত সম্প্রচার_ডিমেনশনস অপারেন্ড হ'ল অপারেশনগুলি সম্প্রচারের জন্য ব্যবহারের জন্য মাত্রাগুলি নির্দিষ্ট করে এমন পূর্ণসংখ্যার একটি টুকরো। শব্দার্থবিজ্ঞানগুলি সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - তুলনা করুন

লে

XlaBuilder::Le দেখুন।

lhs এবং rhs তুলনায় উপাদান-ভিত্তিক কম-বা সমান-সমান-তুলনায় সম্পাদন করে।

\(lhs <= rhs\)

Le(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে

যুক্তিগুলির আকারগুলি হয় একই বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী তা সম্পর্কে সম্প্রচারের ডকুমেন্টেশন দেখুন। অপারেশনের ফলাফলের একটি আকার রয়েছে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই বৈকল্পিকভাবে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে অপারেশনগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির মধ্যে একটি স্কেলার হয়।

বিভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক এলই এর জন্য বিদ্যমান:

Le(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিক বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে গাণিতিক ক্রিয়াকলাপগুলির জন্য ব্যবহার করা উচিত (যেমন কোনও ভেক্টরে ম্যাট্রিক্স যুক্ত করা)।

অতিরিক্ত সম্প্রচার_ডিমেনশনস অপারেন্ড হ'ল অপারেশনগুলি সম্প্রচারের জন্য ব্যবহারের জন্য মাত্রাগুলি নির্দিষ্ট করে এমন পূর্ণসংখ্যার একটি টুকরো। শব্দার্থবিজ্ঞানগুলি সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

কার্যকর করে এলই -র জন্য ভাসমান পয়েন্ট নম্বরগুলির উপর মোট অর্ডার সমর্থন করুন:

\[-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN.\]

LeTotalOrder(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - তুলনা করুন

লে

XlaBuilder::Lt দেখুন।

lhs এবং rhs তুলনায় উপাদান অনুসারে কম- তুলনা করে।

\(lhs < rhs\)

Lt(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে

যুক্তিগুলির আকারগুলি হয় একই বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী তা সম্পর্কে সম্প্রচারের ডকুমেন্টেশন দেখুন। অপারেশনের ফলাফলের একটি আকার রয়েছে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই বৈকল্পিকভাবে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে অপারেশনগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির মধ্যে একটি স্কেলার হয়।

বিভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক এলটি-র জন্য বিদ্যমান:

Lt(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিক বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে গাণিতিক ক্রিয়াকলাপগুলির জন্য ব্যবহার করা উচিত (যেমন কোনও ভেক্টরে ম্যাট্রিক্স যুক্ত করা)।

অতিরিক্ত সম্প্রচার_ডিমেনশনস অপারেন্ড হ'ল অপারেশনগুলি সম্প্রচারের জন্য ব্যবহারের জন্য মাত্রাগুলি নির্দিষ্ট করে এমন পূর্ণসংখ্যার একটি টুকরো। শব্দার্থবিজ্ঞানগুলি সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

কার্যকরভাবে এলটি -র জন্য ভাসমান পয়েন্ট নম্বরগুলির উপর মোট অর্ডার সমর্থন করুন:

\[-NaN < -Inf < -Finite < -0 < +0 < +Finite < +Inf < +NaN.\]

LtTotalOrder(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - তুলনা করুন

জটিল

XlaBuilder::Complex দেখুন।

বাস্তব এবং কল্পিত মান, lhs এবং rhs একজোড়া থেকে একটি জটিল মানতে উপাদান-ভিত্তিক রূপান্তর সম্পাদন করে।

Complex(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে

যুক্তিগুলির আকারগুলি হয় একই বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী তা সম্পর্কে সম্প্রচারের ডকুমেন্টেশন দেখুন। অপারেশনের ফলাফলের একটি আকার রয়েছে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই বৈকল্পিকভাবে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে অপারেশনগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির মধ্যে একটি স্কেলার হয়।

বিভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক কমপ্লেক্সের জন্য বিদ্যমান:

Complex(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিক বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে গাণিতিক ক্রিয়াকলাপগুলির জন্য ব্যবহার করা উচিত (যেমন কোনও ভেক্টরে ম্যাট্রিক্স যুক্ত করা)।

অতিরিক্ত সম্প্রচার_ডিমেনশনস অপারেন্ড হ'ল অপারেশনগুলি সম্প্রচারের জন্য ব্যবহারের জন্য মাত্রাগুলি নির্দিষ্ট করে এমন পূর্ণসংখ্যার একটি টুকরো। শব্দার্থবিজ্ঞানগুলি সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - কমপ্লেক্স

কনকাতিন্ডিম (কনটেনেটেট)

XlaBuilder::ConcatInDim দেখুন।

কনটেনটেট একাধিক অ্যারে অপারেন্ডগুলি থেকে একটি অ্যারে রচনা করে। অ্যারেটির প্রতিটি ইনপুট অ্যারে অপারেন্ডগুলির মতো একই সংখ্যার মাত্রা রয়েছে (যার একে অপরের মতো একই সংখ্যার মাত্রা থাকতে হবে) এবং সেগুলি নির্দিষ্ট করে দেওয়া ক্রমে যুক্তি রয়েছে।

Concatenate(operands..., dimension)

যুক্তি টাইপ শব্দার্থবিদ্যা
operands এন XlaOp এর ক্রম N মাত্রা সহ টাইপ টি এর অ্যারে [এল 0, এল 1, ...]। N> = 1 প্রয়োজন।
dimension int64 ব্যবধানে একটি মান [0, N) যা operands মধ্যে সংমিশ্রিত হওয়ার জন্য মাত্রাটির নাম দেয়।

dimension ব্যতীত সমস্ত মাত্রা অবশ্যই একই হতে হবে। এটি কারণ এক্সএলএ "রাগড" অ্যারে সমর্থন করে না। এছাড়াও নোট করুন যে 0-মাত্রিক মানগুলি সংমিশ্রণ করা যায় না (কারণ সংমিশ্রণটি যে মাত্রাটি ঘটে তার নামকরণ করা অসম্ভব)।

1-মাত্রিক উদাহরণ:

Concat({ {2, 3}, {4, 5}, {6, 7} }, 0)
//Output:  {2, 3, 4, 5, 6, 7}

2-মাত্রিক উদাহরণ:

let a = { {1, 2},
         {3, 4},
         {5, 6} };

let b = { {7, 8} };

Concat({a, b}, 0)

//Output:  { {1, 2},
//          {3, 4},
//          {5, 6},
//          {7, 8} }

চিত্র:

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - কনটেনেট

শর্তসাপেক্ষ

XlaBuilder::Conditional দেখুন।

Conditional(predicate, true_operand, true_computation, false_operand, false_computation)

যুক্তি টাইপ শব্দার্থবিদ্যা
predicate XlaOp টাইপ PRED স্কেলার
true_operand XlaOp প্রকারের যুক্তি \(T_0\)
true_computation XlaComputation প্রকারের xlacomptunation \(T_0 \to S\)
false_operand XlaOp প্রকারের যুক্তি \(T_1\)
false_computation XlaComputation প্রকারের xlacomptunation \(T_1 \to S\)

predicate true হলে true_computation সম্পাদন করে, যদি predicate false হয় তবে false_computation এবং ফলাফলটি ফিরিয়ে দেয়।

true_computation অবশ্যই টাইপের একক যুক্তি গ্রহণ করতে হবে \(T_0\) এবং true_operand সাথে আহ্বান করা হবে যা অবশ্যই একই ধরণের হতে হবে। false_computation অবশ্যই টাইপের একক যুক্তি গ্রহণ করতে হবে \(T_1\) এবং false_operand দিয়ে আহ্বান করা হবে যা অবশ্যই একই ধরণের হতে হবে। true_computation এবং false_computation প্রত্যাবর্তনের মানটির ধরণটি একই হতে হবে।

মনে রাখবেন যে predicate মানের উপর নির্ভর করে true_computation একটি এবং false_computation কার্যকর করা হবে।

Conditional(branch_index, branch_computations, branch_operands)

যুক্তি টাইপ শব্দার্থবিদ্যা
branch_index XlaOp টাইপ S32 এর স্কেলার
branch_computations এন XlaComputation এর ক্রম প্রকারের xlacomputations \(T_0 \to S , T_1 \to S , ..., T_{N-1} \to S\)
branch_operands এন XlaOp এর ক্রম প্রকারের যুক্তি \(T_0 , T_1 , ..., T_{N-1}\)

branch_computations[branch_index] কার্যকর করে এবং ফলাফলটি প্রদান করে। যদি branch_index একটি S32 হয় যা <0 বা> = n হয়, তবে branch_computations[N-1] ডিফল্ট শাখা হিসাবে কার্যকর করা হয়।

প্রতিটি branch_computations[b] অবশ্যই টাইপের একক যুক্তি গ্রহণ করতে হবে \(T_b\) এবং branch_operands[b] এর সাথে আহ্বান করা হবে যা অবশ্যই একই ধরণের হতে হবে। প্রতিটি branch_computations[b] এর প্রত্যাবর্তনের মানের প্রকারটি একই হতে হবে।

নোট করুন যে branch_index মানের উপর নির্ভর করে কেবলমাত্র একটি branch_computations কার্যকর করা হবে।

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - যদি

ধ্রুবক

XlaBuilder::ConstantLiteral দেখুন।

একটি ধ্রুবক literal থেকে একটি output উত্পাদন করে।

Constant(literal)

যুক্তি টাইপ শব্দার্থবিদ্যা
literal LiteralSlice একটি বিদ্যমান Literal অবিচ্ছিন্ন দৃশ্য

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - ধ্রুবক

রূপান্তরকরণ টাইপ

XlaBuilder::ConvertElementType দেখুন।

সি ++ তে একটি উপাদান-ভিত্তিক static_cast অনুরূপ, ConvertElementType একটি ডেটা আকার থেকে লক্ষ্য আকারে একটি উপাদান-ভিত্তিক রূপান্তর অপারেশন সম্পাদন করে। মাত্রাগুলি অবশ্যই মেলে, এবং রূপান্তরটি একটি উপাদান-ভিত্তিক; যেমন s32 উপাদানগুলি একটি s32 -to- f32 রূপান্তর রুটিনের মাধ্যমে f32 উপাদানগুলিতে পরিণত হয়।

ConvertElementType(operand, new_element_type)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ডিমেস ডি সহ টাইপ টি এর অ্যারে
new_element_type PrimitiveType টাইপ ইউ

অপারেন্ডের মাত্রা এবং লক্ষ্য আকৃতি অবশ্যই মেলে। উত্স এবং গন্তব্য উপাদান প্রকারগুলি অবশ্যই teples হওয়া উচিত নয়।

T=s32 এর মতো একটি রূপান্তর যেমন U=f32 তে একটি সাধারণকরণ ইন-টু-ফ্লোট রূপান্তর রুটিন যেমন বৃত্তাকার থেকে নিকটতম-এমনকি।

let a: s32[3] = {0, 1, 2};
let b: f32[3] = convert(a, f32);
then b == f32[3]{0.0, 1.0, 2.0}

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - রূপান্তর করুন

কনভ (কনভোলশন)

XlaBuilder::Conv

নিউরাল নেটওয়ার্কগুলিতে ব্যবহৃত ধরণের একটি সমঝোতা গণনা করে। এখানে, একটি এন-ডাইমেনশনাল উইন্ডো হিসাবে একটি এন-ডাইমেনশনাল বেস অঞ্চল জুড়ে চলমান এবং উইন্ডোটির প্রতিটি সম্ভাব্য অবস্থানের জন্য একটি গণনা সঞ্চালিত হয়।

Conv গণনাটির উপর একটি কনভোলিউশন নির্দেশনা দেয়, যা কোনও প্রসারণ ছাড়াই ডিফল্ট কনভোলিউশন ডাইমেনশন সংখ্যা ব্যবহার করে।

প্যাডিংটি স্বল্প-হাতের উপায়ে একই বা বৈধ হিসাবে নির্দিষ্ট করা হয়। একই প্যাডিং জিরো সহ ইনপুট ( lhs ) প্যাড করে যাতে আউটপুটটি অ্যাকাউন্টে স্ট্রাইডিং না নেওয়ার সময় ইনপুট হিসাবে একই আকার থাকে। বৈধ প্যাডিংয়ের অর্থ কেবল প্যাডিং নেই।

Conv(lhs, rhs, window_strides, padding, feature_group_count, batch_group_count, precision_config, preferred_element_type)

যুক্তি টাইপ শব্দার্থবিদ্যা
lhs XlaOp (এন+2) -পুটগুলির মাত্রিক অ্যারে
rhs XlaOp (এন+2)-কার্নেল ওজনের মাত্রিক অ্যারে
window_strides ArraySlice<int64> কার্নেল স্ট্রাইডের এনডি অ্যারে
padding Padding প্যাডিংয়ের এনাম
feature_group_count int64 বৈশিষ্ট্য গোষ্ঠীর সংখ্যা
batch_group_count int64 ব্যাচ গ্রুপের সংখ্যা
precision_config Pre চ্ছিক PrecisionConfig নির্ভুলতার স্তরের জন্য এনাম
preferred_element_type Al চ্ছিক PrimitiveType স্কেলার উপাদান প্রকারের এনাম

নিয়ন্ত্রণের ক্রমবর্ধমান স্তরগুলি Conv জন্য উপলব্ধ:

আসুন n স্থানিক মাত্রার সংখ্যা হতে দিন। lhs আর্গুমেন্টটি একটি (এন+2)-বেস অঞ্চলটি বর্ণনা করে মাত্রিক অ্যারে। এটিকে ইনপুট বলা হয়, যদিও অবশ্যই আরএইচএসও একটি ইনপুট। একটি নিউরাল নেটওয়ার্কে, এগুলি ইনপুট অ্যাক্টিভেশন। এন+2 মাত্রা এই ক্রমে:

  • batch : এই মাত্রায় প্রতিটি সমন্বয় একটি স্বতন্ত্র ইনপুট উপস্থাপন করে যার জন্য সমঝোতা করা হয়।
  • z/depth/features : বেস অঞ্চলে প্রতিটি (y, x) অবস্থানের সাথে সম্পর্কিত একটি ভেক্টর রয়েছে, যা এই মাত্রায় যায়।
  • spatial_dims : n স্পেসিয়াল ডাইমেনশনগুলি বর্ণনা করে যা উইন্ডোটি জুড়ে চলে যায় এমন বেস অঞ্চলকে সংজ্ঞায়িত করে।

rhs আর্গুমেন্টটি একটি (এন+2)-কনভোলিউশনাল ফিল্টার/কার্নেল/উইন্ডো বর্ণনা করে মাত্রিক অ্যারে। মাত্রাগুলি এই ক্রমে:

  • output-z : আউটপুটটির z মাত্রা।
  • input-z : এই মাত্রার সময়গুলির আকার feature_group_count এলএইচএসে z মাত্রার আকারের সমান হওয়া উচিত।
  • spatial_dims : এনডি উইন্ডোটি সংজ্ঞায়িত করে এমন n স্পেসিয়াল মাত্রাগুলি বর্ণনা করে যা বেস অঞ্চল জুড়ে চলে।

window_strides আর্গুমেন্টটি স্থানিক মাত্রাগুলিতে কনভোলিউশনাল উইন্ডোর প্রবাহ নির্দিষ্ট করে। উদাহরণস্বরূপ, যদি প্রথম স্থানিক মাত্রার স্ট্রাইড 3 হয়, তবে উইন্ডোটি কেবল স্থানাঙ্কে স্থাপন করা যেতে পারে যেখানে প্রথম স্থানিক সূচকটি 3 দ্বারা বিভাজ্য।

padding আর্গুমেন্ট বেস অঞ্চলে প্রয়োগ করার জন্য শূন্য প্যাডিংয়ের পরিমাণ নির্দিষ্ট করে। প্যাডিংয়ের পরিমাণ নেতিবাচক হতে পারে - নেতিবাচক প্যাডিংয়ের পরম মানটি কনভোলিউশন করার আগে নির্দিষ্ট মাত্রা থেকে সরানোর জন্য উপাদানগুলির সংখ্যা নির্দেশ করে। padding[0] মাত্রা y এবং padding[1] মাত্রা x জন্য প্যাডিং নির্দিষ্ট করে। প্রতিটি জুটির প্রথম উপাদান হিসাবে কম প্যাডিং এবং দ্বিতীয় উপাদান হিসাবে উচ্চ প্যাডিং রয়েছে। উচ্চ প্যাডিং উচ্চতর সূচকগুলির দিকে প্রয়োগ করা হলে নিম্ন সূচকগুলির দিকে কম প্যাডিং প্রয়োগ করা হয়। উদাহরণস্বরূপ, যদি padding[1] হয় (2,3) তবে বামদিকে 2 শূন্য দ্বারা এবং দ্বিতীয় স্থানিক মাত্রায় ডানদিকে 3 শূন্য দ্বারা প্যাডিং থাকবে। প্যাডিং ব্যবহার করা কনভোলিউশন করার আগে সেই একই শূন্য মানগুলি ইনপুট ( lhs ) এ প্রবেশের সমতুল্য।

lhs_dilation এবং rhs_dilation আর্গুমেন্টগুলি প্রতিটি স্থানিক মাত্রায় যথাক্রমে এলএইচএস এবং আরএইচএসে প্রয়োগ করার জন্য ডিলেশন ফ্যাক্টর নির্দিষ্ট করে। যদি কোনও স্থানিক মাত্রায় ডিলেশন ফ্যাক্টরটি ডি হয়, তবে ডি -1 গর্তগুলি সেই মাত্রার প্রতিটি এন্ট্রিগুলির মধ্যে স্পষ্টভাবে স্থাপন করা হয়, অ্যারের আকার বাড়িয়ে। গর্তগুলি একটি নো-অপ-মান দিয়ে পূর্ণ হয়, যা কনভোলিউশনের অর্থ শূন্য।

আরএইচএসের প্রসারণকে অ্যাট্রিয়াস কনভোলিউশনও বলা হয়। আরও তথ্যের জন্য, tf.nn.atrous_conv2d দেখুন। এলএইচএসের প্রসারণকে ট্রান্সপোজড কনভোলিউশনও বলা হয়। আরও তথ্যের জন্য, tf.nn.conv2d_transpose দেখুন।

feature_group_count আর্গুমেন্ট (ডিফল্ট মান 1) গোষ্ঠীযুক্ত কনভোলিউশনের জন্য ব্যবহার করা যেতে পারে। feature_group_count ইনপুট এবং আউটপুট বৈশিষ্ট্য মাত্রা উভয়ের বিভাজক হওয়া দরকার। যদি feature_group_count 1 এর চেয়ে বেশি হয় তবে এর অর্থ হ'ল ধারণাগতভাবে ইনপুট এবং আউটপুট বৈশিষ্ট্য মাত্রা এবং rhs আউটপুট বৈশিষ্ট্য মাত্রা সমানভাবে অনেকগুলি feature_group_count গ্রুপে বিভক্ত হয়, প্রতিটি গ্রুপ বৈশিষ্ট্যগুলির একটানা পরবর্তীকালের সমন্বয়ে গঠিত। rhs ইনপুট বৈশিষ্ট্য মাত্রা lhs ইনপুট বৈশিষ্ট্য মাত্রার সমান হওয়া দরকার feature_group_count দ্বারা বিভক্ত (সুতরাং এটি ইতিমধ্যে ইনপুট বৈশিষ্ট্যগুলির একটি গ্রুপের আকার রয়েছে)। আই-থি গ্রুপগুলি একসাথে অনেকগুলি পৃথক কনভোলিউশনের জন্য feature_group_count গণনা করতে একসাথে ব্যবহৃত হয়। এই কনভোলিউশনের ফলাফলগুলি আউটপুট বৈশিষ্ট্য মাত্রায় একত্রিত হয়।

গভীরতার সাথে কনভোলিউশনের জন্য feature_group_count যুক্তিটি ইনপুট বৈশিষ্ট্য মাত্রায় সেট করা হবে এবং ফিল্টারটি [filter_height, filter_width, in_channels, channel_multiplier] থেকে [filter_height, filter_width, 1, in_channels * channel_multiplier] থেকে পুনরায় আকার দেওয়া হবে। আরও তথ্যের জন্য, tf.nn.depthwise_conv2d দেখুন।

batch_group_count (ডিফল্ট মান 1) আর্গুমেন্ট ব্যাকপ্রোপেজেশন চলাকালীন গ্রুপযুক্ত ফিল্টারগুলির জন্য ব্যবহার করা যেতে পারে। batch_group_count lhs (ইনপুট) ব্যাচের মাত্রার আকারের একটি বিভাজক হওয়া দরকার। যদি batch_group_count 1 এর চেয়ে বেশি হয় তবে এর অর্থ হ'ল আউটপুট ব্যাচের মাত্রা আকারের input batch / batch_group_count হওয়া উচিত। batch_group_count অবশ্যই আউটপুট বৈশিষ্ট্য আকারের একটি বিভাজক হতে হবে।

আউটপুট আকারের এই ক্রমে এই মাত্রা রয়েছে:

  • batch : এই মাত্রার সময়গুলির আকার batch_group_count এলএইচএসে batch মাত্রার আকারের সমান হওয়া উচিত।
  • z : কার্নেল ( rhs ) এ output-z হিসাবে একই আকার।
  • spatial_dims : কনভোলিউশনাল উইন্ডোর প্রতিটি বৈধ স্থান নির্ধারণের জন্য একটি মান।

উপরের চিত্রটি দেখায় যে কীভাবে batch_group_count ক্ষেত্রটি কাজ করে। কার্যকরভাবে, আমরা প্রতিটি এলএইচএস ব্যাচকে batch_group_count গ্রুপগুলিতে টুকরো টুকরো করি এবং আউটপুট বৈশিষ্ট্যগুলির জন্য একই কাজ করি। তারপরে, এই গোষ্ঠীর প্রত্যেকটির জন্য আমরা জোড়াযুক্ত কনভোলিউশনগুলি করি এবং আউটপুট বৈশিষ্ট্যটির মাত্রা বরাবর আউটপুটকে একত্রিত করি। অন্যান্য সমস্ত মাত্রার অপারেশনাল শব্দার্থবিজ্ঞান (বৈশিষ্ট্য এবং স্থানিক) একই থাকে।

কনভোলিউশনাল উইন্ডোর বৈধ স্থানগুলি প্যাডিংয়ের পরে স্ট্রাইডস এবং বেস অঞ্চলের আকার দ্বারা নির্ধারিত হয়।

একটি সমঝোতা কী করে তা বর্ণনা করার জন্য, একটি 2 ডি কনভোলিউশন বিবেচনা করুন এবং আউটপুটে কিছু স্থির batch , z , y , x স্থানাঙ্কগুলি বেছে নিন। তারপরে (y,x) হ'ল বেস অঞ্চলের মধ্যে উইন্ডোর একটি কোণার একটি অবস্থান (যেমন আপনি স্থানিক মাত্রাগুলি কীভাবে ব্যাখ্যা করেন তার উপর নির্ভর করে উপরের বাম কোণটি)। আমাদের এখন একটি 2 ডি উইন্ডো রয়েছে, বেস অঞ্চল থেকে নেওয়া, যেখানে প্রতিটি 2 ডি পয়েন্ট 1 ডি ভেক্টরের সাথে সম্পর্কিত, তাই আমরা একটি 3 ডি বাক্স পাই। কনভোলিউশনাল কার্নেল থেকে, যেহেতু আমরা আউটপুট স্থানাঙ্ক z স্থির করেছি, আমাদের একটি 3 ডি বাক্সও রয়েছে। দুটি বাক্সের একই মাত্রা রয়েছে, তাই আমরা দুটি বাক্সের (একটি বিন্দু পণ্যের অনুরূপ) এর মধ্যে উপাদান-ভিত্তিক পণ্যগুলির যোগফল নিতে পারি। এটি আউটপুট মান।

মনে রাখবেন যে output-z যেমন, 5 হয়, তবে উইন্ডোর প্রতিটি অবস্থান আউটপুটটিতে 5 টি মান আউটপুটটির z মাত্রায় উত্পাদন করে। এই মানগুলি কনভোলিউশনাল কার্নেলের কোন অংশে ব্যবহৃত হয় তার মধ্যে পৃথক - প্রতিটি output-z সমন্বয় করার জন্য ব্যবহৃত মানগুলির একটি পৃথক 3 ডি বাক্স রয়েছে। সুতরাং আপনি এটিকে প্রত্যেকের জন্য আলাদা ফিল্টার সহ 5 টি পৃথক কনভোলিউশন হিসাবে ভাবতে পারেন।

প্যাডিং এবং স্ট্রাইডিং সহ 2 ডি কনভোলিউশনের জন্য এখানে সিউডো-কোড রয়েছে:

for (b, oz, oy, ox) { // output coordinates
  value = 0;
  for (iz, ky, kx) { // kernel coordinates and input z
    iy = oy*stride_y + ky - pad_low_y;
    ix = ox*stride_x + kx - pad_low_x;
    if ((iy, ix) inside the base area considered without padding) {
      value += input(b, iz, iy, ix) * kernel(oz, iz, ky, kx);
    }
  }
  output(b, oz, oy, ox) = value;
}

নির্ভুলতা কনফিগারেশনটি নির্দেশ করতে precision_config ব্যবহৃত হয়। স্তরটি নির্ধারণ করে যে হার্ডওয়্যারটি যখন প্রয়োজন হয় তখন আরও সঠিক ডিটিওয়াইপি এমুলেশন সরবরাহের জন্য আরও মেশিন কোড নির্দেশাবলী উত্পন্ন করার চেষ্টা করা উচিত কিনা তা নির্ধারণ করে (অর্থাত্ একটি টিপিইউতে এফ 32 অনুকরণকারী যা কেবল বিএফ 16 ম্যাটমুলকে সমর্থন করে)। মানগুলি DEFAULT হতে পারে, HIGH , HIGHESTএমএক্সইউ বিভাগগুলিতে অতিরিক্ত বিশদ।

preferred_element_type হ'ল উচ্চতর/নিম্ন নির্ভুলতা আউটপুট প্রকারের একটি স্কেলার উপাদান যা জমা হওয়ার জন্য ব্যবহৃত হয়। preferred_element_type প্রদত্ত অপারেশনের জন্য জমে থাকা ধরণের প্রস্তাব দেয়, তবে এটি গ্যারান্টিযুক্ত নয়। এটি কিছু হার্ডওয়্যার ব্যাকেন্ডের পরিবর্তে পরিবর্তে আলাদা ধরণের সংগ্রহ করতে এবং পছন্দসই আউটপুট প্রকারে রূপান্তর করতে দেয়।

স্থিতিশীল তথ্যের জন্য স্টেবলহ্লো - কনভোলিউশন দেখুন।

কনফেনারালপ্যাডিং

XlaBuilder::ConvWithGeneralPadding দেখুন।

ConvWithGeneralPadding(lhs, rhs, window_strides, padding, feature_group_count, batch_group_count, precision_config, preferred_element_type)

প্যাডিং কনফিগারেশন সুস্পষ্ট যেখানে Conv হিসাবে একই।

যুক্তি টাইপ শব্দার্থবিদ্যা
lhs XlaOp (এন+2) -পুটগুলির মাত্রিক অ্যারে
rhs XlaOp (এন+2)-কার্নেল ওজনের মাত্রিক অ্যারে
window_strides ArraySlice<int64> কার্নেল স্ট্রাইডের এনডি অ্যারে
padding ArraySlice< pair<int64,int64>> (নিম্ন, উচ্চ) প্যাডিংয়ের এনডি অ্যারে
feature_group_count int64 বৈশিষ্ট্য গোষ্ঠীর সংখ্যা
batch_group_count int64 ব্যাচ গ্রুপের সংখ্যা
precision_config Pre চ্ছিক PrecisionConfig নির্ভুলতার স্তরের জন্য এনাম
preferred_element_type Al চ্ছিক PrimitiveType স্কেলার উপাদান প্রকারের এনাম

কনফেনারাল ডাইমেনশনস

XlaBuilder::ConvWithGeneralDimensions দেখুন।

ConvWithGeneralDimensions(lhs, rhs, window_strides, padding, dimension_numbers, feature_group_count, batch_group_count, precision_config, preferred_element_type)

Conv যেখানে ডাইমেনশন সংখ্যাগুলি সুস্পষ্ট।

যুক্তি টাইপ শব্দার্থবিদ্যা
lhs XlaOp (এন+2) -পুটগুলির মাত্রিক অ্যারে
rhs XlaOp (এন+2)-কার্নেল ওজনের মাত্রিক অ্যারে
window_strides ArraySlice<int64> কার্নেল স্ট্রাইডের এনডি অ্যারে
padding Padding প্যাডিংয়ের এনাম
dimension_numbers ConvolutionDimensionNumbers মাত্রা সংখ্যা
feature_group_count int64 বৈশিষ্ট্য গোষ্ঠীর সংখ্যা
batch_group_count int64 ব্যাচ গ্রুপের সংখ্যা
precision_config Pre চ্ছিক PrecisionConfig নির্ভুলতার স্তরের জন্য এনাম
preferred_element_type Al চ্ছিক PrimitiveType স্কেলার উপাদান প্রকারের এনাম

কনভিজেনারাল

XlaBuilder::ConvGeneral দেখুন।

ConvGeneral(lhs, rhs, window_strides, padding, dimension_numbers, feature_group_count, batch_group_count, precision_config, preferred_element_type)

Conv যেখানে ডাইমেনশন সংখ্যা এবং প্যাডিং কনফিগারেশন সুস্পষ্ট

যুক্তি টাইপ শব্দার্থবিদ্যা
lhs XlaOp (এন+2) -পুটগুলির মাত্রিক অ্যারে
rhs XlaOp (এন+2)-কার্নেল ওজনের মাত্রিক অ্যারে
window_strides ArraySlice<int64> কার্নেল স্ট্রাইডের এনডি অ্যারে
padding ArraySlice< pair<int64,int64>> (নিম্ন, উচ্চ) প্যাডিংয়ের এনডি অ্যারে
dimension_numbers ConvolutionDimensionNumbers মাত্রা সংখ্যা
feature_group_count int64 বৈশিষ্ট্য গোষ্ঠীর সংখ্যা
batch_group_count int64 ব্যাচ গ্রুপের সংখ্যা
precision_config Pre চ্ছিক PrecisionConfig নির্ভুলতার স্তরের জন্য এনাম
preferred_element_type Al চ্ছিক PrimitiveType স্কেলার উপাদান প্রকারের এনাম

কনভেনরালডিলেটেড

XlaBuilder::ConvGeneralDilated দেখুন।

ConvGeneralDilated(lhs, rhs, window_strides, padding, lhs_dilation, rhs_dilation, dimension_numbers, feature_group_count, batch_group_count, precision_config, preferred_element_type, window_reversal)

প্যাডিং কনফিগারেশন, প্রসারণ উপাদান এবং মাত্রা সংখ্যাগুলি সুস্পষ্ট যেখানে Conv হিসাবে একই।

যুক্তি টাইপ শব্দার্থবিদ্যা
lhs XlaOp (এন+2) -পুটগুলির মাত্রিক অ্যারে
rhs XlaOp (এন+2)-কার্নেল ওজনের মাত্রিক অ্যারে
window_strides ArraySlice<int64> কার্নেল স্ট্রাইডের এনডি অ্যারে
padding ArraySlice< pair<int64,int64>> (নিম্ন, উচ্চ) প্যাডিংয়ের এনডি অ্যারে
lhs_dilation ArraySlice<int64> এনডি এলএইচএস ডিলেশন ফ্যাক্টর অ্যারে
rhs_dilation ArraySlice<int64> এনডি আরএইচএস ডিলেশন ফ্যাক্টর অ্যারে
dimension_numbers ConvolutionDimensionNumbers মাত্রা সংখ্যা
feature_group_count int64 বৈশিষ্ট্য গোষ্ঠীর সংখ্যা
batch_group_count int64 ব্যাচ গ্রুপের সংখ্যা
precision_config Pre চ্ছিক PrecisionConfig নির্ভুলতার স্তরের জন্য এনাম
preferred_element_type Al চ্ছিক PrimitiveType স্কেলার উপাদান প্রকারের এনাম
window_reversal Al চ্ছিক vector<bool> সমঝোতা প্রয়োগের আগে পতাকা যৌক্তিকভাবে বিপরীত মাত্রা ব্যবহার করতে ব্যবহৃত

কপি

HloInstruction::CreateCopyStart দেখুন।

Copy অভ্যন্তরীণভাবে 2 এইচএলও নির্দেশাবলী CopyStart এবং CopyDone মধ্যে পচে যায়। Copy CopyStart এবং অনুলিপি সহ CopyDone এইচএলওতে আদিম হিসাবে কাজ করে। এই ওপিগুলি এইচএলও ডাম্পগুলিতে উপস্থিত হতে পারে, তবে এগুলি শেষ ব্যবহারকারীরা ম্যানুয়ালি নির্মিত হওয়ার উদ্দেশ্যে নয়।

কারণ

XlaBuilder::Cos দেখুন।

উপাদান অনুসারে কোসাইন x -> cos(x)

Cos(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ফাংশন অপারেন্ড

সিওএসও al চ্ছিক result_accuracy আর্গুমেন্টকে সমর্থন করে:

Cos(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ফাংশন অপারেন্ড
result_accuracy al চ্ছিক ResultAccuracy সাথে ব্যবহারকারী একাধিক বাস্তবায়নের সাথে ইউনারি ওপিএসের জন্য অনুরোধ করতে পারে এমন প্রকারের ধরণ

result_accuracy সম্পর্কে আরও তথ্যের জন্য ফলাফলের নির্ভুলতা দেখুন।

স্থিতিশীল তথ্যের জন্য স্টেবলহ্লো - কোসাইন দেখুন।

কশ

XlaBuilder::Cosh দেখুন।

উপাদান -ভিত্তিক হাইপারবোলিক কোসাইন x -> cosh(x)

Cosh(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ফাংশন অপারেন্ড

COSH চ্ছিক result_accuracy আর্গুমেন্টকেও সমর্থন করে:

Cosh(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp ফাংশন অপারেন্ড
result_accuracy al চ্ছিক ResultAccuracy সাথে ব্যবহারকারী একাধিক বাস্তবায়নের সাথে ইউনারি ওপিএসের জন্য অনুরোধ করতে পারে এমন প্রকারের ধরণ

result_accuracy সম্পর্কে আরও তথ্যের জন্য ফলাফলের নির্ভুলতা দেখুন।

কাস্টমকল

XlaBuilder::CustomCall দেখুন।

একটি গণনার মধ্যে ব্যবহারকারী-সরবরাহিত ফাংশন কল করুন।

কাস্টমকল ডকুমেন্টেশন বিকাশকারী বিবরণে সরবরাহ করা হয় - এক্সএলএ কাস্টম কল

স্থিতিশীল তথ্যের জন্য স্টেবলহ্লো - কাস্টম_ক্যাল দেখুন।

বিভাগ

XlaBuilder::Div

লভ্যাংশ lhs এবং বিভাজক rhs উপাদান-ভিত্তিক বিভাগ সম্পাদন করে।

Div(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে

পূর্ণসংখ্যা বিভাগ ওভারফ্লো (স্বাক্ষরিত/স্বাক্ষরবিহীন বিভাগ/শূন্য দ্বারা অবশিষ্টাংশ বা স্বাক্ষরিত বিভাগ/ -1 এর সাথে INT_SMIN এর অবশিষ্টাংশ) একটি বাস্তবায়ন সংজ্ঞায়িত মান উত্পাদন করে।

যুক্তিগুলির আকারগুলি হয় একই বা সামঞ্জস্যপূর্ণ হতে হবে। আকারগুলি সামঞ্জস্যপূর্ণ হওয়ার জন্য এর অর্থ কী তা সম্পর্কে সম্প্রচারের ডকুমেন্টেশন দেখুন। অপারেশনের ফলাফলের একটি আকার রয়েছে যা দুটি ইনপুট অ্যারে সম্প্রচারের ফলাফল। এই বৈকল্পিকভাবে, বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে অপারেশনগুলি সমর্থিত নয় , যদি না অপারেন্ডগুলির মধ্যে একটি স্কেলার হয়।

বিভিন্ন-মাত্রিক সম্প্রচার সমর্থন সহ একটি বিকল্প বৈকল্পিক ডিভের জন্য বিদ্যমান:

Div(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
আরএইচএস Xlaop বাম-পাশের দিকের অপারেন্ড: টাইপ টি এর অ্যারে
সম্প্রচার_ডিমেনশন অ্যারেলিস লক্ষ্য আকারে কোন মাত্রা অপারেন্ড আকারের প্রতিটি মাত্রার সাথে মিলে যায়

অপারেশনের এই বৈকল্পিক বিভিন্ন র‌্যাঙ্কের অ্যারেগুলির মধ্যে গাণিতিক ক্রিয়াকলাপগুলির জন্য ব্যবহার করা উচিত (যেমন কোনও ভেক্টরে ম্যাট্রিক্স যুক্ত করা)।

অতিরিক্ত সম্প্রচার_ডিমেনশনস অপারেন্ড হ'ল অপারেশনগুলি সম্প্রচারের জন্য ব্যবহারের জন্য মাত্রাগুলি নির্দিষ্ট করে এমন পূর্ণসংখ্যার একটি টুকরো। শব্দার্থবিজ্ঞানগুলি সম্প্রচার পৃষ্ঠায় বিশদভাবে বর্ণনা করা হয়েছে।

স্থিতিশীল তথ্যের জন্য স্থিতিশীল দেখুন - ভাগ করুন

ডোমেইন

HloInstruction::CreateDomain দেখুন।

Domain এইচএলও ডাম্পগুলিতে উপস্থিত হতে পারে, তবে এটি শেষ ব্যবহারকারীরা ম্যানুয়ালি তৈরি করার উদ্দেশ্যে নয়।

ডট

XlaBuilder::Dot দেখুন।

Dot(lhs, rhs, precision_config, preferred_element_type)

যুক্তি টাইপ শব্দার্থবিদ্যা
lhs XlaOp টাইপ টি এর অ্যারে
rhs XlaOp টাইপ টি এর অ্যারে
precision_config Pre চ্ছিক PrecisionConfig নির্ভুলতার স্তরের জন্য এনাম
preferred_element_type Al চ্ছিক PrimitiveType স্কেলার উপাদান প্রকারের এনাম

এই অপারেশনের সঠিক শব্দার্থবিজ্ঞানগুলি অপারেশনগুলির র‌্যাঙ্কগুলির উপর নির্ভর করে:

ইনপুট আউটপুট শব্দার্থবিদ্যা
ভেক্টর [এন] dot ভেক্টর [এন] স্কেলার ভেক্টর ডট পণ্য
ম্যাট্রিক্স [এমএক্সকে] dot ভেক্টর [কে] ভেক্টর [এম] ম্যাট্রিক্স-ভেক্টর গুণ
ম্যাট্রিক্স [এমএক্সকে] dot ম্যাট্রিক্স [কেএক্সএন] ম্যাট্রিক্স [এমএক্সএন] ম্যাট্রিক্স-ম্যাট্রিক্স গুণ

অপারেশনটি lhs দ্বিতীয় মাত্রা (বা এটি যদি 1 টি মাত্রা থাকে তবে প্রথম) এবং rhs প্রথম মাত্রা জুড়ে পণ্যগুলির যোগফল সম্পাদন করে। এগুলি হ'ল "চুক্তিবদ্ধ" মাত্রা। lhs এবং rhs চুক্তিবদ্ধ মাত্রা একই আকারের হতে হবে। অনুশীলনে, এটি ভেক্টর, ভেক্টর/ম্যাট্রিক্স গুণ বা ম্যাট্রিক্স/ম্যাট্রিক্স গুণগুলির মধ্যে ডট পণ্য সম্পাদন করতে ব্যবহার করা যেতে পারে।

নির্ভুলতা কনফিগারেশনটি নির্দেশ করতে precision_config ব্যবহৃত হয়। স্তরটি নির্ধারণ করে যে হার্ডওয়্যারটি যখন প্রয়োজন হয় তখন আরও সঠিক ডিটিওয়াইপি এমুলেশন সরবরাহের জন্য আরও মেশিন কোড নির্দেশাবলী উত্পন্ন করার চেষ্টা করা উচিত কিনা তা নির্ধারণ করে (অর্থাত্ একটি টিপিইউতে এফ 32 অনুকরণকারী যা কেবল বিএফ 16 ম্যাটমুলকে সমর্থন করে)। মানগুলি DEFAULT হতে পারে, HIGH , HIGHESTএমএক্সইউ বিভাগগুলিতে অতিরিক্ত বিশদ।

preferred_element_type হ'ল উচ্চতর/নিম্ন নির্ভুলতা আউটপুট প্রকারের একটি স্কেলার উপাদান যা জমা হওয়ার জন্য ব্যবহৃত হয়। preferred_element_type প্রদত্ত অপারেশনের জন্য জমে থাকা ধরণের প্রস্তাব দেয়, তবে এটি গ্যারান্টিযুক্ত নয়। এটি কিছু হার্ডওয়্যার ব্যাকেন্ডের পরিবর্তে পরিবর্তে আলাদা ধরণের সংগ্রহ করতে এবং পছন্দসই আউটপুট প্রকারে রূপান্তর করতে দেয়।

স্থিতিশীল তথ্যের জন্য স্টেবলহ্লো - ডট দেখুন।

ডটজেনারাল

XlaBuilder::DotGeneral দেখুন।

DotGeneral(lhs, rhs, dimension_numbers, precision_config, preferred_element_type)

যুক্তি টাইপ শব্দার্থবিদ্যা
lhs XlaOp টাইপ টি এর অ্যারে
rhs XlaOp টাইপ টি এর অ্যারে
dimension_numbers DotDimensionNumbers চুক্তি এবং ব্যাচের মাত্রা সংখ্যা
precision_config Pre চ্ছিক PrecisionConfig নির্ভুলতার স্তরের জন্য এনাম
preferred_element_type Al চ্ছিক PrimitiveType স্কেলার উপাদান প্রকারের এনাম

ডটের মতো, তবে চুক্তি এবং ব্যাচের মাত্রা সংখ্যাগুলি lhs এবং rhs উভয়ের জন্য নির্দিষ্ট করার অনুমতি দেয়।

ডটডিমেনশননবার্স ফিল্ডস টাইপ শব্দার্থবিদ্যা
lhs_contracting_dimensions পুনরাবৃত্তি int64 lhs চুক্তি মাত্রা সংখ্যা
rhs_contracting_dimensions পুনরাবৃত্তি int64 rhs চুক্তি মাত্রা সংখ্যা
lhs_batch_dimensions পুনরাবৃত্তি int64 lhs ব্যাচের মাত্রা সংখ্যা
rhs_batch_dimensions পুনরাবৃত্তি int64 rhs ব্যাচের মাত্রা সংখ্যা

ডটজেনারাল dimension_numbers নির্দিষ্ট চুক্তির মাত্রাগুলির চেয়ে পণ্যগুলির যোগফল সম্পাদন করে।

lhs এবং rhs থেকে সম্পর্কিত চুক্তির মাত্রা সংখ্যাগুলি একই হওয়ার দরকার নেই তবে একই মাত্রার আকার থাকতে হবে।

চুক্তির মাত্রা সংখ্যা সহ উদাহরণ:

lhs = { {1.0, 2.0, 3.0},
        {4.0, 5.0, 6.0} }

rhs = { {1.0, 1.0, 1.0},
        {2.0, 2.0, 2.0} }

DotDimensionNumbers dnums;
dnums.add_lhs_contracting_dimensions(1);
dnums.add_rhs_contracting_dimensions(1);

DotGeneral(lhs, rhs, dnums) -> { { 6.0, 12.0},
                                 {15.0, 30.0} }

lhs এবং rhs থেকে সম্পর্কিত ব্যাচের মাত্রা সংখ্যাগুলির একই মাত্রা আকার থাকতে হবে।

ব্যাচের মাত্রা সংখ্যা (ব্যাচের আকার 2, 2x2 ম্যাট্রিকেস) সহ উদাহরণ:

lhs = { { {1.0, 2.0},
          {3.0, 4.0} },
        { {5.0, 6.0},
          {7.0, 8.0} } }

rhs = { { {1.0, 0.0},
          {0.0, 1.0} },
        { {1.0, 0.0},
          {0.0, 1.0} } }

DotDimensionNumbers dnums;
dnums.add_lhs_contracting_dimensions(2);
dnums.add_rhs_contracting_dimensions(1);
dnums.add_lhs_batch_dimensions(0);
dnums.add_rhs_batch_dimensions(0);

DotGeneral(lhs, rhs, dnums) -> {
    { {1.0, 2.0},
      {3.0, 4.0} },
    { {5.0, 6.0},
      {7.0, 8.0} } }
ইনপুট আউটপুট শব্দার্থবিদ্যা
[বি 0, এম, কে] dot [বি 0, কে, এন] [বি 0, এম, এন] ব্যাচ ম্যাটমুল
[বি 0, বি 1, এম, কে] dot [বি 0, বি 1, কে, এন] [বি 0, বি 1, এম, এন] ব্যাচ ম্যাটমুল

এটি অনুসরণ করে যে ফলাফলের মাত্রা সংখ্যাটি ব্যাচের মাত্রা দিয়ে শুরু হয়, তারপরে lhs নন-কন্ট্রাক্টিং/নন-ব্যাচের মাত্রা এবং অবশেষে rhs নন-কন্ট্রাক্টিং/নন-ব্যাচের মাত্রা।

নির্ভুলতা কনফিগারেশনটি নির্দেশ করতে precision_config ব্যবহৃত হয়। স্তরটি নির্ধারণ করে যে হার্ডওয়্যারটি যখন প্রয়োজন হয় তখন আরও সঠিক ডিটিওয়াইপি এমুলেশন সরবরাহের জন্য আরও মেশিন কোড নির্দেশাবলী উত্পন্ন করার চেষ্টা করা উচিত কিনা তা নির্ধারণ করে (অর্থাত্ একটি টিপিইউতে এফ 32 অনুকরণকারী যা কেবল বিএফ 16 ম্যাটমুলকে সমর্থন করে)। মানগুলি DEFAULT হতে পারে, HIGH , HIGHEST । অতিরিক্ত বিশদ এমএক্সইউ বিভাগগুলিতে পাওয়া যাবে

preferred_element_type হ'ল উচ্চতর/নিম্ন নির্ভুলতা আউটপুট প্রকারের একটি স্কেলার উপাদান যা জমা হওয়ার জন্য ব্যবহৃত হয়। preferred_element_type প্রদত্ত অপারেশনের জন্য জমে থাকা ধরণের প্রস্তাব দেয়, তবে এটি গ্যারান্টিযুক্ত নয়। এটি কিছু হার্ডওয়্যার ব্যাকেন্ডের পরিবর্তে পরিবর্তে আলাদা ধরণের সংগ্রহ করতে এবং পছন্দসই আউটপুট প্রকারে রূপান্তর করতে দেয়।

স্থিতিশীল তথ্যের জন্য স্টেবলহ্লো - ডট_ জেনারেল দেখুন।

স্কেলডট

XlaBuilder::ScaledDot দেখুন।

ScaledDot(lhs, lhs_scale, rhs, rhs_scale, dimension_number, precision_config,preferred_element_type)

যুক্তি টাইপ শব্দার্থবিদ্যা
lhs XlaOp টাইপ টি এর অ্যারে
rhs XlaOp টাইপ টি এর অ্যারে
lhs_scale XlaOp টাইপ টি এর অ্যারে
rhs_scale XlaOp টাইপ টি এর অ্যারে
dimension_number ScatterDimensionNumbers স্ক্যাটার অপারেশনের জন্য মাত্রা সংখ্যা
precision_config PrecisionConfig নির্ভুলতার স্তরের জন্য এনাম
preferred_element_type Al চ্ছিক PrimitiveType স্কেলার উপাদান প্রকারের এনাম

ডটজেনারালের মতো।

অপারেন্ডস 'এলএইচএস', 'এলএইচএস_স্কেল', 'আরএইচএস', এবং 'আরএইচএস_স্কেল' সহ একটি স্কেলড ডট অপার তৈরি করে, 'ডাইমেনশন_নম্বারস' এ নির্দিষ্ট করা চুক্তি এবং ব্যাচের মাত্রা সহ।

রাগডডট

XlaBuilder::RaggedDot দেখুন।

RaggedDot গণনার একটি ভাঙ্গনের জন্য দেখুন স্থিতিশীলহ্লো - clo.ragged_dot

ডায়নামিকরশেপ

XlaBuilder::DynamicReshape দেখুন।

এই অপারেশনটি পুনরায় আকার দেওয়ার মতো কার্যত অভিন্ন, তবে ফলাফলের আকারটি আউটপুট_শেপের মাধ্যমে গতিশীলভাবে নির্দিষ্ট করা হয়।

DynamicReshape(operand, dim_sizes, new_size_bounds, dims_are_dynamic)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp টাইপ টি এর ডাইমেনশনাল অ্যারে
dim_sizes XlaOP ভেক্টর N মাত্রিক ভেক্টর আকার
new_size_bounds int63 এর ভেক্টর সীমানা n মাত্রিক ভেক্টর
dims_are_dynamic bool ভেক্টর N মাত্রিক গতিশীল ম্লান

স্থিতিশীল তথ্যের জন্য স্টেবলহ্লো - ডায়নামিক_রশেপ দেখুন।

ডায়নামিক্সলিস

XlaBuilder::DynamicSlice দেখুন।

ডায়নামিক্সলিস ডায়নামিক start_indices ইনপুট অ্যারে থেকে একটি সাব-অ্যারে নিষ্কাশন করে। The size of the slice in each dimension is passed in size_indices , which specify the end point of exclusive slice intervals in each dimension: [start, start + size). The shape of start_indices must be 1-dimensional, with dimension size equal to the number of dimensions of operand .

DynamicSlice(operand, start_indices, slice_sizes)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp N dimensional array of type T
start_indices sequence of N XlaOp List of N scalar integers containing the starting indices of the slice for each dimension. Value must be greater than or equal to zero.
size_indices ArraySlice<int64> List of N integers containing the slice size for each dimension. Each value must be strictly greater than zero, and start + size must be less than or equal to the size of the dimension to avoid wrapping modulo dimension size.

The effective slice indices are computed by applying the following transformation for each index i in [1, N) before performing the slice:

start_indices[i] = clamp(start_indices[i], 0, operand.dimension_size[i] - slice_sizes[i])

This ensures that the extracted slice is always in-bounds with respect to the operand array. If the slice is in-bounds before the transformation is applied, the transformation has no effect.

1-dimensional example:

let a = {0.0, 1.0, 2.0, 3.0, 4.0};
let s = {2};

DynamicSlice(a, s, {2});
// Result: {2.0, 3.0}

2-dimensional example:

let b =
{ {0.0,  1.0,  2.0},
  {3.0,  4.0,  5.0},
  {6.0,  7.0,  8.0},
  {9.0, 10.0, 11.0} }
let s = {2, 1}

DynamicSlice(b, s, {2, 2});
//Result:
// { { 7.0,  8.0},
//   {10.0, 11.0} }

For StableHLO information see StableHLO - dynamic_slice .

DynamicUpdateSlice

See also XlaBuilder::DynamicUpdateSlice .

DynamicUpdateSlice generates a result which is the value of the input array operand , with a slice update overwritten at start_indices . The shape of update determines the shape of the sub-array of the result which is updated. The shape of start_indices must be 1-dimensional, with dimension size equal to the number of dimensions of operand .

DynamicUpdateSlice(operand, update, start_indices)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp N dimensional array of type T
update XlaOp N dimensional array of type T containing the slice update. Each dimension of update shape must be strictly greater than zero, and start + update must be less than or equal to the operand size for each dimension to avoid generating out-of-bounds update indices.
start_indices sequence of N XlaOp List of N scalar integers containing the starting indices of the slice for each dimension. Value must be greater than or equal to zero.

The effective slice indices are computed by applying the following transformation for each index i in [1, N) before performing the slice:

start_indices[i] = clamp(start_indices[i], 0, operand.dimension_size[i] - update.dimension_size[i])

This ensures that the updated slice is always in-bounds with respect to the operand array. If the slice is in-bounds before the transformation is applied, the transformation has no effect.

1-dimensional example:

let a = {0.0, 1.0, 2.0, 3.0, 4.0}
let u = {5.0, 6.0}
let s = {2}

DynamicUpdateSlice(a, u, s)
// Result: {0.0, 1.0, 5.0, 6.0, 4.0}

2-dimensional example:

let b =
{ {0.0,  1.0,  2.0},
  {3.0,  4.0,  5.0},
  {6.0,  7.0,  8.0},
  {9.0, 10.0, 11.0} }
let u =
{ {12.0, 13.0},
  {14.0, 15.0},
  {16.0, 17.0} }

let s = {1, 1}

DynamicUpdateSlice(b, u, s)
// Result:
// { {0.0,  1.0,  2.0},
//   {3.0, 12.0, 13.0},
//   {6.0, 14.0, 15.0},
//   {9.0, 16.0, 17.0} }

For StableHLO information see StableHLO - dynamic_update_slice .

এরফ

See also XlaBuilder::Erf .

Element-wise error function x -> erf(x) where:

\(\text{erf}(x) = \frac{2}{\sqrt{\pi} }\int_0^x e^{-t^2} \, dt\).

Erf(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Erf also supports the optional result_accuracy argument:

Erf(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

মেয়াদ

See also XlaBuilder::Exp .

Element-wise natural exponential x -> e^x .

Exp(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Exp also supports the optional result_accuracy argument:

Exp(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

For StableHLO information see StableHLO - exponential .

Expm1

See also XlaBuilder::Expm1 .

Element-wise natural exponential minus one x -> e^x - 1 .

Expm1(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Expm1 also supports the optional result_accuracy argument:

Expm1(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

For StableHLO information see StableHLO - exponential_minus_one .

Fft

See also XlaBuilder::Fft .

The XLA FFT operation implements the forward and inverse Fourier Transforms for real and complex inputs/outputs. Multidimensional FFTs on up to 3 axes are supported.

Fft(operand, ftt_type, fft_length)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The array we are Fourier transforming.
fft_type FftType নীচের টেবিল দেখুন.
fft_length ArraySlice<int64> The time-domain lengths of the axes being transformed. This is needed in particular for IRFFT to right-size the innermost axis, since RFFT(fft_length=[16]) has the same output shape as RFFT(fft_length=[17]) .
FftType শব্দার্থবিদ্যা
FFT Forward complex-to-complex FFT. Shape is unchanged.
IFFT Inverse complex-to-complex FFT. Shape is unchanged.
RFFT Forward real-to-complex FFT. Shape of the innermost axis is reduced to fft_length[-1] // 2 + 1 if fft_length[-1] is a non-zero value, omitting the reversed conjugate part of the transformed signal beyond the Nyquist frequency.
IRFFT Inverse real-to-complex FFT (ie takes complex, returns real). Shape of the innermost axis is expanded to fft_length[-1] if fft_length[-1] is a non-zero value, inferring the part of the transformed signal beyond the Nyquist frequency from the reverse conjugate of the 1 to fft_length[-1] // 2 + 1 entries.

For StableHLO information see StableHLO - fft .

Multidimensional FFT

When more than 1 fft_length is provided, this is equivalent to applying a cascade of FFT operations to each of the innermost axes. Note that for the real->complex and complex->real cases, the innermost axis transform is (effectively) performed first (RFFT; last for IRFFT), which is why the innermost axis is the one which changes size. Other axis transforms will then be complex->complex.

বাস্তবায়নের বিবরণ

CPU FFT is backed by Eigen's TensorFFT. GPU FFT uses cuFFT.

মেঝে

See also XlaBuilder::Floor .

Element-wise floor x -> ⌊x⌋ .

Floor(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

For StableHLO information see StableHLO - floor .

ফিউশন

See also HloInstruction::CreateFusion .

Fusion operation represents HLO instructions and serves as a primitive in HLO. This op may appear in HLO dumps but is not intended to be constructed manually by end users.

জড়ো করা

The XLA gather operation stitches together several slices (each slice at a potentially different runtime offset) of an input array.

For StableHLO information see StableHLO - gather .

General Semantics

See also XlaBuilder::Gather . For a more intuitive description, see the "Informal Description" section below.

gather(operand, start_indices, dimension_numbers, slice_sizes, indices_are_sorted)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The array we're gathering from.
start_indices XlaOp Array containing the starting indices of the slices we gather.
dimension_numbers GatherDimensionNumbers The dimension in start_indices that "contains" the starting indices. See below for a detailed description.
slice_sizes ArraySlice<int64> slice_sizes[i] is the bounds for the slice on dimension i .
indices_are_sorted bool Whether the indices are guaranteed to be sorted by the caller.

For convenience, we label dimensions in the output array not in offset_dims as batch_dims .

The output is an array with batch_dims.size + offset_dims.size dimensions.

The operand.rank must equal the sum of offset_dims.size and collapsed_slice_dims.size . Also, slice_sizes.size has to be equal to operand.rank .

If index_vector_dim is equal to start_indices.rank we implicitly consider start_indices to have a trailing 1 dimension (ie if start_indices was of shape [6,7] and index_vector_dim is 2 then we implicitly consider the shape of start_indices to be [6,7,1] ).

The bounds for the output array along dimension i is computed as follows:

  1. If i is present in batch_dims (ie is equal to batch_dims[k] for some k ) then we pick the corresponding dimension bounds out of start_indices.shape , skipping index_vector_dim (ie pick start_indices.shape.dims [ k ] if k < index_vector_dim and start_indices.shape.dims [ k + 1 ] otherwise).

  2. If i is present in offset_dims (ie equal to offset_dims [ k ] for some k ) then we pick the corresponding bound out of slice_sizes after accounting for collapsed_slice_dims (ie we pick adjusted_slice_sizes [ k ] where adjusted_slice_sizes is slice_sizes with the bounds at indices collapsed_slice_dims সরানো)।

Formally, the operand index In corresponding to a given output index Out is calculated as follows:

  1. Let G = { Out [ k ] for k in batch_dims }. Use G to slice out a vector S such that S [ i ] = start_indices [Combine( G , i )] where Combine(A, b) inserts b at position index_vector_dim into A. Note that this is well defined even if G is empty: If G is empty then S = start_indices .

  2. Create a starting index, S in , into operand using S by scattering S using start_index_map . আরো সঠিকভাবে:

    1. S in [ start_index_map [ k ]] = S [ k ] if k < start_index_map.size .

    2. S in [ _ ] = 0 otherwise.

  3. Create an index O in into operand by scattering the indices at the offset dimensions in Out according to the collapsed_slice_dims set. আরো সঠিকভাবে:

    1. O in [ remapped_offset_dims ( k )] = Out [ offset_dims [ k ]] if k < offset_dims.size ( remapped_offset_dims is defined below).

    2. O in [ _ ] = 0 otherwise.

  4. In is O in + S in where + is element-wise addition.

remapped_offset_dims is a monotonic function with domain [ 0 , offset_dims.size ) and range [ 0 , operand.rank ) \ collapsed_slice_dims . So if, eg, offset_dims.size is 4 , operand.rank is 6 and collapsed_slice_dims is { 0 , 2 } then remapped_offset_dims is { 01 , 13 , 24 , 35 }.

If indices_are_sorted is set to true then XLA can assume that start_indices are sorted (in ascending order, after scattering its values according to start_index_map ) by the user. If they are not then the semantics are implementation defined.

Informal Description and Examples

Informally, every index Out in the output array corresponds to an element E in the operand array, computed as follows:

  • We use the batch dimensions in Out to look up a starting index from start_indices .

  • We use start_index_map to map the starting index (whose size may be less than operand.rank) to a "full" starting index into the operand .

  • We dynamic-slice out a slice with size slice_sizes using the full starting index.

  • We reshape the slice by collapsing the collapsed_slice_dims dimensions. Since all collapsed slice dimensions must have a bound of 1, this reshape is always legal.

  • We use the offset dimensions in Out to index into this slice to get the input element, E , corresponding to output index Out .

index_vector_dim is set to start_indices.rank - 1 in all of the examples that follow. More interesting values for index_vector_dim do not change the operation fundamentally, but make the visual representation more cumbersome.

To get an intuition on how all of the above fits together, let's look at an example that gathers 5 slices of shape [8,6] from a [16,11] array. The position of a slice into the [16,11] array can be represented as an index vector of shape S64[2] , so the set of 5 positions can be represented as a S64[5,2] array.

The behavior of the gather operation can then be depicted as an index transformation that takes [ G , O 0 , O 1 ], an index in the output shape, and maps it to an element in the input array in the following way:

We first select an ( X , Y ) vector from the gather indices array using G . The element in the output array at index [ G , O 0 , O 1 ] is then the element in the input array at index [ X + O 0 , Y + O 1 ].

slice_sizes is [8,6] , which decides the range of O 0 and O 1 , and this in turn decides the bounds of the slice.

This gather operation acts as a batch dynamic slice with G as the batch dimension.

The gather indices may be multidimensional. For instance, a more general version of the example above using a "gather indices" array of shape [4,5,2] would translate indices like this:

Again, this acts as a batch dynamic slice G 0 and G 1 as the batch dimensions. The slice size is still [8,6] .

The gather operation in XLA generalizes the informal semantics outlined above in the following ways:

  1. We can configure which dimensions in the output shape are the offset dimensions (dimensions containing O 0 , O 1 in the last example). The output batch dimensions (dimensions containing G 0 , G 1 in the last example) are defined to be the output dimensions that are not offset dimensions.

  2. The number of output offset dimensions explicitly present in the output shape may be smaller than the input number of dimensions. These "missing" dimensions, which are listed explicitly as collapsed_slice_dims , must have a slice size of 1 . Since they have a slice size of 1 the only valid index for them is 0 and eliding them does not introduce ambiguity.

  3. The slice extracted from the "Gather Indices" array (( X , Y ) in the last example) may have fewer elements than the input array's number of dimensions, and an explicit mapping dictates how the index should be expanded to have the same number of dimensions as the input.

As a final example, we use (2) and (3) to implement tf.gather_nd :

G 0 and G 1 are used to slice out a starting index from the gather indices array as usual, except the starting index has only one element, X . Similarly, there is only one output offset index with the value O 0 . However, before being used as indices into the input array, these are expanded in accordance to "Gather Index Mapping" ( start_index_map in the formal description) and "Offset Mapping" ( remapped_offset_dims in the formal description) into [ X , 0 ] and [ 0 , O 0 ] respectively, adding up to [ X , O 0 ]. In other words, the output index [ G 0 , G 1 , O 0 ] maps to the input index [ GatherIndices [ G 0 , G 1 , 0 ], O 0 ] which gives us the semantics for tf.gather_nd .

slice_sizes for this case is [1,11] . Intuitively this means that every index X in the gather indices array picks an entire row and the result is the concatenation of all these rows.

GetDimensionSize

See also XlaBuilder::GetDimensionSize .

Returns the size of the given dimension of the operand. The operand must be array shaped.

GetDimensionSize(operand, dimension)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp n dimensional input array
dimension int64 A value in the interval [0, n) that specifies the dimension

For StableHLO information see StableHLO - get_dimension_size .

GetTupleElement

See also XlaBuilder::GetTupleElement .

Indexes into a tuple with a compile-time-constant value.

The value must be a compile-time-constant so that shape inference can determine the type of the resulting value.

This is analogous to std::get<int N>(t) in C++. Conceptually:

let v: f32[10] = f32[10]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
let s: s32 = 5;
let t: (f32[10], s32) = tuple(v, s);
let element_1: s32 = gettupleelement(t, 1); // Inferred shape matches s32.

See also tf.tuple .

GetTupleElement(tuple_data, index)

যুক্তি টাইপ শব্দার্থবিদ্যা
tuple_data XlaOP The tuple
index int64 Index of tuple shape

For StableHLO information see StableHLO - get_tuple_element .

ইমেজ

See also XlaBuilder::Imag .

Element-wise imaginary part of a complex (or real) shape. x -> imag(x) . If the operand is a floating point type, returns 0.

Imag(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

For StableHLO information see StableHLO - imag .

Infeed

See also XlaBuilder::Infeed .

Infeed(shape, config)

যুক্তি টাইপ শব্দার্থবিদ্যা
shape Shape Shape of the data read from the Infeed interface. The layout field of the shape must be set to match the layout of the data sent to the device; otherwise its behavior is undefined.
config optional string Configuration of the op.

Reads a single data item from the implicit Infeed streaming interface of the device, interpreting the data as the given shape and its layout, and returns a XlaOp of the data. Multiple Infeed operations are allowed in a computation, but there must be a total order among the Infeed operations. For example, two Infeed 's in the code below have a total order since there is a dependency between the while loops.

result1 = while (condition, init = init_value) {
  Infeed(shape)
  }

result2 = while (condition, init = result1) {
  Infeed(shape)
  }

Nested tuple shapes are not supported. For an empty tuple shape, the Infeed operation is effectively a no-op and proceeds without reading any data from the Infeed of the device.

For StableHLO information see StableHLO - infeed .

আইওটা

See also XlaBuilder::Iota .

Iota(shape, iota_dimension)

Builds a constant literal on device rather than a potentially large host transfer. Creates an array that has specified shape and holds values starting at zero and incrementing by one along the specified dimension. For floating-point types, the produced array is equivalent to ConvertElementType(Iota(...)) where the Iota is of integral type and the conversion is to the floating-point type.

যুক্তি টাইপ শব্দার্থবিদ্যা
shape Shape Shape of the array created by Iota()
iota_dimension int64 The dimension to increment along.

For example, Iota(s32[4, 8], 0) returns

[[0, 0, 0, 0, 0, 0, 0, 0 ],
 [1, 1, 1, 1, 1, 1, 1, 1 ],
 [2, 2, 2, 2, 2, 2, 2, 2 ],
 [3, 3, 3, 3, 3, 3, 3, 3 ]]

Iota(s32[4, 8], 1) returns

[[0, 1, 2, 3, 4, 5, 6, 7 ],
 [0, 1, 2, 3, 4, 5, 6, 7 ],
 [0, 1, 2, 3, 4, 5, 6, 7 ],
 [0, 1, 2, 3, 4, 5, 6, 7 ]]

For StableHLO information see StableHLO - iota .

IsFinite

See also XlaBuilder::IsFinite .

Tests whether each element of operand is finite, ie, is not positive or negative infinity, and is not NaN . Returns an array of PRED values with the same shape as the input, where each element is true if and only if the corresponding input element is finite.

IsFinite(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

For StableHLO information see StableHLO - is_finite .

লগ

See also XlaBuilder::Log .

Element-wise natural logarithm x -> ln(x) .

Log(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Log also supports the optional result_accuracy argument:

Log(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

For StableHLO information see StableHLO - log .

Log1p

See also XlaBuilder::Log1p .

Element-wise shifted natural logarithm x -> ln(1+x) .

Log1p(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Log1p also supports the optional result_accuracy argument:

Log1p(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

For StableHLO information see StableHLO - log_plus_one .

লজিস্টিক

See also XlaBuilder::Logistic .

Element-wise logistic function computation x -> logistic(x) .

Logistic(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Logistic also supports the optional result_accuracy argument:

Logistic(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

For StableHLO information see StableHLO - logistic .

মানচিত্র

See also XlaBuilder::Map .

Map(operands..., computation, dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
operands sequence of N XlaOp s N arrays of types T 0..T {N-1}
computation XlaComputation Computation of type T_0, T_1, .., T_{N + M -1} -> S with N parameters of type T and M of arbitrary type.
dimensions int64 array Array of map dimensions
static_operands sequence of N XlaOp s Static ops for the map operation

Applies a scalar function over the given operands arrays, producing an array of the same dimensions where each element is the result of the mapped function applied to the corresponding elements in the input arrays.

The mapped function is an arbitrary computation with the restriction that it has N inputs of scalar type T and a single output with type S . The output has the same dimensions as the operands except that the element type T is replaced with S.

For example: Map(op1, op2, op3, computation, par1) maps elem_out <- computation(elem1, elem2, elem3, par1) at each (multi-dimensional) index in the input arrays to produce the output array.

For StableHLO information see StableHLO - map .

সর্বোচ্চ

See also XlaBuilder::Max .

Performs element-wise max operation on tensors lhs and rhs .

Max(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for Max:

Max(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - maximum .

মিন

See also XlaBuilder::Min .

Performs element-wise min operation on lhs and rhs .

Min(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for Min:

Min(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - minimum .

মুল

See also XlaBuilder::Mul .

Performs element-wise product of lhs and rhs .

Mul(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for Mul:

Mul(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - multiply .

নেগ

See also XlaBuilder::Neg .

Element-wise negation x -> -x .

Neg(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

For StableHLO information see StableHLO - negate

না

See also XlaBuilder::Not .

Element-wise logical not x -> !(x) .

Not(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

For StableHLO information see StableHLO - not .

OptimizationBarrier

See also XlaBuilder::OptimizationBarrier .

Blocks any optimization pass from moving computations across the barrier.

OptimizationBarrier(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Ensures that all inputs are evaluated before any operators that depend on the barrier's outputs.

For StableHLO information see StableHLO - optimization_barrier .

বা

See also XlaBuilder::Or .

Performs element-wise OR of lhs and rhs .

Or(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for Or:

Or(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - or .

Outfeed

See also XlaBuilder::Outfeed .

Writes inputs to the outfeed.

Outfeed(operand, shape_with_layout, outfeed_config)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp array of type T
shape_with_layout Shape Defines the layout of the data transferred
outfeed_config string Constant of config for the Outfeed instruction

shape_with_layout communicates the laid out shape that we want to outfeed.

For StableHLO information see StableHLO - outfeed .

প্যাড

See also XlaBuilder::Pad .

Pad(operand, padding_value, padding_config)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp array of type T
padding_value XlaOp scalar of type T to fill in the added padding
padding_config PaddingConfig padding amount on both edges (low, high) and between the elements of each dimension

Expands the given operand array by padding around the array as well as between the elements of the array with the given padding_value . padding_config specifies the amount of edge padding and the interior padding for each dimension.

PaddingConfig is a repeated field of PaddingConfigDimension , which contains three fields for each dimension: edge_padding_low , edge_padding_high , and interior_padding .

edge_padding_low and edge_padding_high specify the amount of padding added at the low-end (next to index 0) and the high-end (next to the highest index) of each dimension respectively. The amount of edge padding can be negative -- the absolute value of negative padding indicates the number of elements to remove from the specified dimension.

interior_padding specifies the amount of padding added between any two elements in each dimension; it may not be negative. Interior padding occurs logically before edge padding, so in the case of negative edge padding, elements are removed from the interior-padded operand.

This operation is a no-op if the edge padding pairs are all (0, 0) and the interior padding values are all 0. The figure below shows examples of different edge_padding and interior_padding values for a two-dimensional array.

For StableHLO information see StableHLO - pad .

প্যারামিটার

See also XlaBuilder::Parameter .

Parameter represents an argument input to a computation.

PartitionID

See also XlaBuilder::BuildPartitionId .

Produces partition_id of the current process.

PartitionID(shape)

যুক্তি টাইপ শব্দার্থবিদ্যা
shape Shape Shape of the data

PartitionID may appear in HLO dumps but it is not intended to be constructed manually by end users.

For StableHLO information see StableHLO - partition_id .

PopulationCount

See also XlaBuilder::PopulationCount .

Computes the number of bits set in each element of operand .

PopulationCount(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

For StableHLO information see StableHLO - popcnt .

পো

See also XlaBuilder::Pow .

Performs element-wise exponentiation of lhs by rhs .

Pow(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for Pow:

Pow(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - power .

রিয়াল

See also XlaBuilder::Real .

Element-wise real part of a complex (or real) shape. x -> real(x) . If the operand is a floating point type, Real returns the same value.

Real(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

For StableHLO information see StableHLO - real .

Recv

See also XlaBuilder::Recv .

Recv , RecvWithTokens , and RecvToHost are operations that serve as communication primitives in HLO. These ops typically appear in HLO dumps as part of low-level input/output or cross-device transfer, but they are not intended to be constructed manually by end users.

Recv(shape, handle)

যুক্তি টাইপ শব্দার্থবিদ্যা
shape Shape shape of the data to receive
handle ChannelHandle unique identifier for each send/recv pair

Receives data of the given shape from a Send instruction in another computation that shares the same channel handle. Returns a XlaOp for the received data.

For StableHLO information see StableHLO - recv .

RecvDone

See also HloInstruction::CreateRecv and HloInstruction::CreateRecvDone .

Similar to Send , the client API of Recv operation represents synchronous communication. However, the instruction is internally decomposed into 2 HLO instructions ( Recv and RecvDone ) to enable asynchronous data transfers.

Recv(const Shape& shape, int64 channel_id)

Allocates resources required to receive data from a Send instruction with the same channel_id. Returns a context for the allocated resources, which is used by a following RecvDone instruction to wait for the completion of the data transfer. The context is a tuple of {receive buffer (shape), request identifier (U32)} and it can only be used by a RecvDone instruction.

Given a context created by a Recv instruction, waits for the data transfer to complete and return the received data.

কমিয়ে দিন

See also XlaBuilder::Reduce .

Applies a reduction function to one or more arrays in parallel.

Reduce(operands..., init_values..., computation, dimensions_to_reduce)

যুক্তি টাইপ শব্দার্থবিদ্যা
operands Sequence of N XlaOp N arrays of types T_0,..., T_{N-1} .
init_values Sequence of N XlaOp N scalars of types T_0,..., T_{N-1} .
computation XlaComputation computation of type T_0,..., T_{N-1}, T_0, ...,T_{N-1} -> Collate(T_0,..., T_{N-1}) .
dimensions_to_reduce int64 array unordered array of dimensions to reduce.

কোথায়:

  • N is required to be greater or equal to 1.
  • The computation has to be "roughly" associative (see below).
  • All input arrays must have the same dimensions.
  • All initial values have to form an identity under computation .
  • If N = 1 , Collate(T) is T .
  • If N > 1 , Collate(T_0, ..., T_{N-1}) is a tuple of N elements of type T .

This operation reduces one or more dimensions of each input array into scalars. The number of dimensions of each returned array is number_of_dimensions(operand) - len(dimensions) . The output of the op is Collate(Q_0, ..., Q_N) where Q_i is an array of type T_i , the dimensions of which are described below.

Different backends are allowed to reassociate the reduction computation. This can lead to numerical differences, as some reduction functions like addition are not associative for floats. However, if the range of the data is limited, floating-point addition is close enough to be associative for most practical uses.

For StableHLO information see StableHLO - reduce .

উদাহরণ

When reducing across one dimension in a single 1D array with values [10, 11, 12, 13] , with reduction function f (this is computation ) then that could be computed as

f(10, f(11, f(12, f(init_value, 13)))

but there are also many other possibilities, eg

f(init_value, f(f(10, f(init_value, 11)), f(f(init_value, 12), f(init_value, 13))))

The following is a rough pseudo-code example of how reduction could be implemented, using summation as the reduction computation with an initial value of 0.

result_shape <- remove all dims in dimensions from operand_shape

# Iterate over all elements in result_shape. The number of r's here is equal
# to the number of dimensions of the result.
for r0 in range(result_shape[0]), r1 in range(result_shape[1]), ...:
  # Initialize this result element
  result[r0, r1...] <- 0

  # Iterate over all the reduction dimensions
  for d0 in range(dimensions[0]), d1 in range(dimensions[1]), ...:
    # Increment the result element with the value of the operand's element.
    # The index of the operand's element is constructed from all ri's and di's
    # in the right order (by construction ri's and di's together index over the
    # whole operand shape).
    result[r0, r1...] += operand[ri... di]

Here's an example of reducing a 2D array (matrix). The shape has 2 dimensions, dimension 0 of size 2 and dimension 1 of size 3:

Results of reducing dimensions 0 or 1 with an "add" function:

Note that both reduction results are 1D arrays. The diagram shows one as column and another as row just for visual convenience.

For a more complex example, here is a 3D array. Its number of dimensions is 3, dimension 0 of size 4, dimension 1 of size 2 and dimension 2 of size 3. For simplicity, the values 1 to 6 are replicated across dimension 0.

Similarly to the 2D example, we can reduce just one dimension. If we reduce dimension 0, for example, we get a 2-dimensional array where all values across dimension 0 were folded into a scalar:

|  4   8  12 |
| 16  20  24 |

If we reduce dimension 2, we also get a 2-dimensional array where all values across dimension 2 were folded into a scalar:

| 6  15 |
| 6  15 |
| 6  15 |
| 6  15 |

Note that the relative order between the remaining dimensions in the input is preserved in the output, but some dimensions may get assigned new numbers (since the number of dimensions changes).

We can also reduce multiple dimensions. Add-reducing dimensions 0 and 1 produces the 1D array [20, 28, 36] .

Reducing the 3D array over all its dimensions produces the scalar 84 .

Variadic Reduce

When N > 1 , reduce function application is slightly more complex, as it is applied simultaneously to all inputs. The operands are supplied to the computation in the following order:

  • Running reduced value for the first operand
  • ...
  • Running reduced value for the N'th operand
  • Input value for the first operand
  • ...
  • Input value for the N'th operand

For example, consider the following reduction function, which can be used to compute the max and the argmax of a 1-D array in parallel:

f: (Float, Int, Float, Int) -> Float, Int
f(max, argmax, value, index):
  if value >= max:
    return (value, index)
  else:
    return (max, argmax)

For 1-D Input arrays V = Float[N], K = Int[N] , and init values I_V = Float, I_K = Int , the result f_(N-1) of reducing across the only input dimension is equivalent to the following recursive application:

f_0 = f(I_V, I_K, V_0, K_0)
f_1 = f(f_0.first, f_0.second, V_1, K_1)
...
f_(N-1) = f(f_(N-2).first, f_(N-2).second, V_(N-1), K_(N-1))

Applying this reduction to an array of values, and an array of sequential indices (ie iota), will co-iterate over the arrays, and return a tuple containing the maximal value and the matching index.

ReducePrecision

See also XlaBuilder::ReducePrecision .

Models the effect of converting floating-point values to a lower-precision format (such as IEEE-FP16) and back to the original format. The number of exponent and mantissa bits in the lower-precision format can be specified arbitrarily, although all bit sizes may not be supported on all hardware implementations.

ReducePrecision(operand, exponent_bits, mantissa_bits)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp array of floating-point type T .
exponent_bits int32 number of exponent bits in lower-precision format
mantissa_bits int32 number of mantissa bits in lower-precision format

The result is an array of type T . The input values are rounded to the nearest value representable with the given number of mantissa bits (using "ties to even" semantics), and any values that exceed the range specified by the number of exponent bits are clamped to positive or negative infinity. NaN values are retained, although they may be converted to canonical NaN values.

The lower-precision format must have at least one exponent bit (in order to distinguish a zero value from an infinity, since both have a zero mantissa), and must have a non-negative number of mantissa bits. The number of exponent or mantissa bits may exceed the corresponding value for type T ; the corresponding portion of the conversion is then simply a no-op.

For StableHLO information see StableHLO - reduce_precision .

ReduceScatter

See also XlaBuilder::ReduceScatter .

ReduceScatter is a collective operation that effectively does an AllReduce and then scatters the result by splitting it into shard_count blocks along the scatter_dimension and replica i in the replica group receives the ith shard.

ReduceScatter(operand, computation, scatter_dimension, shard_count, replica_groups, channel_id, layout, use_global_device_ids)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp Array or a non-empty tuple of arrays to reduce across replicas.
computation XlaComputation Reduction computation
scatter_dimension int64 Dimension to scatter.
shard_count int64 Number of blocks to split scatter_dimension
replica_groups ReplicaGroup vector Groups between which the reductions are performed
channel_id optional ChannelHandle Optional channel ID for cross-module communication
layout optional Layout user-specified memory layout
use_global_device_ids optional bool user-specified flag
  • When operand is a tuple of arrays, the reduce-scatter is performed on each element of the tuple.
  • replica_groups is a list of replica groups between which the reduction is performed (replica id for the current replica can be retrieved using ReplicaId ). The order of replicas in each group determines the order in which the all-reduce result will be scattered. replica_groups must either be empty (in which case all replicas belong to a single group), or contain the same number of elements as the number of replicas. When there are more than one replica groups, they all must be of the same size. For example, replica_groups = {0, 2}, {1, 3} performs reduction between the replicas 0 and 2 , and 1 and 3 and then scatters the result.
  • shard_count is the size of each replica group. We need this in cases where replica_groups are empty. If replica_groups is not empty, shard_count must be equal to the size of each replica group.
  • channel_id is used for cross-module communication: only reduce-scatter operations with the same channel_id can communicate with each other.
  • layout See xla::shapes for more information on layouts.
  • use_global_device_ids is a user-specified flag. When false (default) the numbers in replica_groups are ReplicaId when true the replica_groups represent a global id of ( ReplicaID * partition_count + partition_id ). যেমন:
    • With 2 replicas and 4 partitions,
    • replica_groups={ {0,1,4,5},{2,3,6,7} } and use_global_device_ids=true
    • group[0] = (0,0), (0,1), (1,0), (1,1)
    • group[1] = (0,2), (0,3), (1,2), (1,3)
    • where each pair is (replica_id, partition_id).

The output shape is the input shape with the scatter_dimension made shard_count times smaller. For example, if there are two replicas and the operand has the value [1.0, 2.25] and [3.0, 5.25] respectively on the two replicas, then the output value from this op where scatter_dim is 0 will be [4.0] for the first replica and [7.5] for the second replica.

For StableHLO information see StableHLO - reduce_scatter .

ReduceScatter - Example 1 - StableHLO

An example of ReduceScatter dataflow for StableHLO

In the above example, there are 2 replicas participating in the ReduceScatter. On each replica, the operand has shape f32[2,4]. An all-reduce (sum) is performed across the replicas, producing a reduced value of shape f32[2,4] on each replica. This reduced value is then split into 2 parts along dimension 1, so each part has shape f32[2,2]. Each replica within the process group receives the part corresponding to its position in the group. As a result, the output on each replica has shape f32[2,2].

ReduceWindow

See also XlaBuilder::ReduceWindow .

Applies a reduction function to all elements in each window of a sequence of N multi-dimensional arrays, producing a single or a tuple of N multi-dimensional arrays as output. Each output array has the same number of elements as the number of valid positions of the window. A pooling layer can be expressed as a ReduceWindow . Similar to Reduce , the applied computation is always passed the init_values on the left-hand side.

ReduceWindow(operands..., init_values..., computation, window_dimensions, window_strides, padding)

যুক্তি টাইপ শব্দার্থবিদ্যা
operands N XlaOps A sequence of N multi-dimensional arrays of types T_0,..., T_{N-1} , each representing the base area on which the window is placed.
init_values N XlaOps The N starting values for the reduction, one for each of the N operands. See Reduce for details.
computation XlaComputation Reduction function of type T_0, ..., T_{N-1}, T_0, ..., T_{N-1} -> Collate(T_0, ..., T_{N-1}) , to apply to elements in each window of all the input operands.
window_dimensions ArraySlice<int64> array of integers for window dimension values
window_strides ArraySlice<int64> array of integers for window stride values
base_dilations ArraySlice<int64> array of integers for base dilation values
window_dilations ArraySlice<int64> array of integers for window dilation values
padding Padding padding type for window (Padding::kSame, which pads so as to have the same output shape as input if the stride is 1, or Padding::kValid, which uses no padding and "stops" the window once it no longer fits)

কোথায়:

  • N is required to be greater or equal to 1.
  • All input arrays must have the same dimensions.
  • If N = 1 , Collate(T) is T .
  • If N > 1 , Collate(T_0, ..., T_{N-1}) is a tuple of N elements of type (T0,...T{N-1}) .

For StableHLO information see StableHLO - reduce_window .

ReduceWindow - Example 1

Input is a matrix of size [4x6] and both window_dimensions and window_stride_dimensions are [2x3].

// Create a computation for the reduction (maximum).
XlaComputation max;
{
  XlaBuilder builder(client_, "max");
  auto y = builder.Parameter(0, ShapeUtil::MakeShape(F32, {}), "y");
  auto x = builder.Parameter(1, ShapeUtil::MakeShape(F32, {}), "x");
  builder.Max(y, x);
  max = builder.Build().value();
}

// Create a ReduceWindow computation with the max reduction computation.
XlaBuilder builder(client_, "reduce_window_2x3");
auto shape = ShapeUtil::MakeShape(F32, {4, 6});
auto input = builder.Parameter(0, shape, "input");
builder.ReduceWindow(
    input,
    /*init_val=*/builder.ConstantLiteral(LiteralUtil::MinValue(F32)),
    *max,
    /*window_dimensions=*/{2, 3},
    /*window_stride_dimensions=*/{2, 3},
    Padding::kValid);

Stride of 1 in a dimension specifies that the position of a window in the dimension is 1 element away from its adjacent window. In order to specify that no windows overlap with each other, window_stride_dimensions should be equal to window_dimensions. The figure below illustrates the use of two different stride values. Padding is applied to each dimension of the input and the calculations are the same as though the input came in with the dimensions it has after padding.

For a non-trivial padding example, consider computing reduce-window minimum (initial value is MAX_FLOAT ) with dimension 3 and stride 2 over the input array [10000, 1000, 100, 10, 1] . Padding kValid computes minimums over two valid windows: [10000, 1000, 100] and [100, 10, 1] , resulting in the output [100, 1] . Padding kSame first pads the array so that the shape after the reduce-window would be the same as input for stride one by adding initial elements on both sides, getting [MAX_VALUE, 10000, 1000, 100, 10, 1, MAX_VALUE] . Running reduce-window over the padded array operates on three windows [MAX_VALUE, 10000, 1000] , [1000, 100, 10] , [10, 1, MAX_VALUE] , and yields [1000, 10, 1] .

The evaluation order of the reduction function is arbitrary and may be non-deterministic. Therefore, the reduction function should not be overly sensitive to reassociation. See the discussion about associativity in the context of Reduce for more details.

ReduceWindow - Example 2 - StableHLO

An example of ReduceWindow dataflow for StableHLO

উপরের উদাহরণে:

Input) The operand has an input shape of S32[3,2]. With a values of [[1,2],[3,4],[5,6]]

Step 1) Base dilation with factor 2 along the row dimension inserts holes between each row of the operand. Padding of 2 rows at the top and 1 row at the bottom is applied after dilation. As a result, the tensor becomes taller.

Step 2) A window of shape [2,1] is defined, with window dilation [3,1]. This means each window selects two elements from the same column, but the second element is taken three rows below the first rather than directly beneath it.

Step 3) The windows are then slid across the operand with stride [4,1]. This causes the window to move down four rows at a time, while shifting one column at a time horizontally. Padding cells are filled with the init_value (in this case init_value = 0 ). Values 'falling into' dilation cells are ignored. Because of the stride and padding, some windows overlap only zeros and holes, while others overlap real input values.

Step 4) Within each window, the elements are combined using the reduction function (a, b) → a + b, starting from an initial value of 0. The top two windows see only padding and holes, so their results are 0. The bottom windows capture the values 3 and 4 from the input and return those as results.

Results) The final output has shape S32[2,2], with values: [[0,0],[3,4]]

রেম

See also XlaBuilder::Rem .

Performs element-wise remainder of dividend lhs and divisor rhs .

The sign of the result is taken from the dividend, and the absolute value of the result is always less than the divisor's absolute value.

Rem(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for Rem:

Rem(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - remainder .

ReplicaId

See also XlaBuilder::ReplicaId .

Returns the unique ID (U32 scalar) of the replica.

ReplicaId()

The unique ID of each replica is an unsigned integer in the interval [0, N) , where N is the number of replicas. Since all the replicas are running the same program, a ReplicaId() call in the program will return a different value on each replica.

For StableHLO information see StableHLO - replica_id .

নতুন আকার দিন

See also XlaBuilder::Reshape . and the Collapse operation.

Reshapes the dimensions of an array into a new configuration.

Reshape(operand, dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp array of type T
dimensions int64 vector vector of sizes of new dimensions

Conceptually, reshape first flattens an array into a one-dimensional vector of data values, and then refines this vector into a new shape. The input arguments are an arbitrary array of type T, a compile-time-constant vector of dimension indices, and a compile-time-constant vector of dimension sizes for the result. The dimensions vector determines the size of the output array. The value at index 0 in dimensions is the size of dimension 0, the value at index 1 is the size of dimension 1, and so on. The product of the dimensions dimensions must equal the product of the operand's dimension sizes. When refining the collapsed array into the multidimensional array defined by dimensions , the dimensions in dimensions are ordered from slowest varying (most major) and to fastest varying (most minor).

For example, let v be an array of 24 elements:

let v = f32[4x2x3] { { {10, 11, 12}, {15, 16, 17} },
                    { {20, 21, 22}, {25, 26, 27} },
                    { {30, 31, 32}, {35, 36, 37} },
                    { {40, 41, 42}, {45, 46, 47} } };

let v012_24 = Reshape(v, {24});
then v012_24 == f32[24] {10, 11, 12, 15, 16, 17, 20, 21, 22, 25, 26, 27,
                         30, 31, 32, 35, 36, 37, 40, 41, 42, 45, 46, 47};

let v012_83 = Reshape(v, {8,3});
then v012_83 == f32[8x3] { {10, 11, 12}, {15, 16, 17},
                          {20, 21, 22}, {25, 26, 27},
                          {30, 31, 32}, {35, 36, 37},
                          {40, 41, 42}, {45, 46, 47} };

As a special case, reshape can transform a single-element array to a scalar and vice versa. যেমন,

Reshape(f32[1x1] { {5} }, {}) == 5;
Reshape(5, {1,1}) == f32[1x1] { {5} };

For StableHLO information see StableHLO - reshape .

Reshape (explicit)

See also XlaBuilder::Reshape .

Reshape(shape, operand)

Reshape op that uses an explicit target shape.

যুক্তি টাইপ শব্দার্থবিদ্যা
shape Shape Output shape of type T
operand XlaOp array of type T

Rev (reverse)

See also XlaBuilder::Rev .

Rev(operand, dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp array of type T
dimensions ArraySlice<int64> dimensions to reverse

Reverses the order of elements in the operand array along the specified dimensions , generating an output array of the same shape. Each element of the operand array at a multidimensional index is stored into the output array at a transformed index. The multidimensional index is transformed by reversing the index in each dimension to be reversed (ie, if a dimension of size N is one of the reversing dimensions, its index i is transformed into N - 1 - i).

One use for the Rev operation is to reverse the convolution weight array along the two window dimensions during the gradient computation in neural networks.

For StableHLO information see StableHLO - reverse .

RngNormal

See also XlaBuilder::RngNormal .

Constructs an output of a given shape with random numbers generated following the \(N(\mu, \sigma)\) স্বাভাবিক বিতরণ। পরামিতি \(\mu\) এবং \(\sigma\), and output shape have to have a floating point elemental type. The parameters furthermore have to be scalar valued.

RngNormal(mu, sigma, shape)

যুক্তি টাইপ শব্দার্থবিদ্যা
mu XlaOp Scalar of type T specifying mean of generated numbers
sigma XlaOp Scalar of type T specifying standard deviation of generated
shape Shape Output shape of type T

For StableHLO information see StableHLO - rng .

RngUniform

See also XlaBuilder::RngUniform .

Constructs an output of a given shape with random numbers generated following the uniform distribution over the interval \([a,b)\). The parameters and output element type have to be a boolean type, an integral type or a floating point types, and the types have to be consistent. The CPU and GPU backends currently only support F64, F32, F16, BF16, S64, U64, S32 and U32. Furthermore, the parameters need to be scalar valued. যদি \(b <= a\) the result is implementation-defined.

RngUniform(a, b, shape)

যুক্তি টাইপ শব্দার্থবিদ্যা
a XlaOp Scalar of type T specifying lower limit of interval
b XlaOp Scalar of type T specifying upper limit of interval
shape Shape Output shape of type T

For StableHLO information see StableHLO - rng .

RngBitGenerator

See also XlaBuilder::RngBitGenerator .

Generates an output with a given shape filled with uniform random bits using the specified algorithm (or backend default) and returns an updated state (with the same shape as initial state) and the generated random data.

Initial state is the initial state of the current random number generation. It and the required shape and valid values are dependent on the algorithm used.

The output is guaranteed to be a deterministic function of the initial state but it is not guaranteed to be deterministic between backends and different compiler versions.

RngBitGenerator(algorithm, initial_state, shape)

যুক্তি টাইপ শব্দার্থবিদ্যা
algorithm RandomAlgorithm PRNG algorithm to be used.
initial_state XlaOp Initial state for the PRNG algorithm.
shape Shape Output shape for generated data.

Available values for algorithm :

For StableHLO information see StableHLO - rng_bit_generator .

RngGetAndUpdateState

See also HloInstruction::CreateRngGetAndUpdateState .

The API of the various Rng operations are internally decomposed into HLO instructions including RngGetAndUpdateState .

RngGetAndUpdateState serves as a primitive in HLO. This op may appear in HLO dumps, but it is not intended to be constructed manually by end users.

গোলাকার

See also XlaBuilder::Round .

Element-wise rounding, ties away from zero.

Round(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

RoundNearestAfz

See also XlaBuilder::RoundNearestAfz .

Performs element-wise rounding towards the nearest integer, breaking ties away from zero.

RoundNearestAfz(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

For StableHLO information see StableHLO - round_nearest_afz .

RoundNearestEven

See also XlaBuilder::RoundNearestEven .

Element-wise rounding, ties to the nearest even.

RoundNearestEven(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

For StableHLO information see StableHLO - round_nearest_even .

Rsqrt

See also XlaBuilder::Rsqrt .

Element-wise reciprocal of square root operation x -> 1.0 / sqrt(x) .

Rsqrt(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Rsqrt also supports the optional result_accuracy argument:

Rsqrt(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

For StableHLO information see StableHLO - rsqrt .

বিক্ষিপ্ত

See also XlaBuilder::Scatter .

The XLA scatter operation generates a sequence of results which are the values of the input array operands , with several slices (at indices specified by scatter_indices ) updated with the sequence of values in updates using update_computation .

Scatter(operands..., scatter_indices, updates..., update_computation, dimension_numbers, indices_are_sorted, unique_indices)

যুক্তি টাইপ শব্দার্থবিদ্যা
operands Sequence of N XlaOp N arrays of types T_0, ..., T_N to be scattered into.
scatter_indices XlaOp Array containing the starting indices of the slices that must be scattered to.
updates Sequence of N XlaOp N arrays of types T_0, ..., T_N . updates[i] contains the values that must be used for scattering operands[i] .
update_computation XlaComputation Computation to be used for combining the existing values in the input array and the updates during scatter. This computation should be of type T_0, ..., T_N, T_0, ..., T_N -> Collate(T_0, ..., T_N) .
index_vector_dim int64 The dimension in scatter_indices that contains the starting indices.
update_window_dims ArraySlice<int64> The set of dimensions in updates shape that are window dimensions .
inserted_window_dims ArraySlice<int64> The set of window dimensions that must be inserted into updates shape.
scatter_dims_to_operand_dims ArraySlice<int64> A dimensions map from the scatter indices to the operand index space. This array is interpreted as mapping i to scatter_dims_to_operand_dims[i] . It has to be one-to-one and total.
dimension_number ScatterDimensionNumbers Dimension numbers for scatter operation
indices_are_sorted bool Whether the indices are guaranteed to be sorted by the caller.
unique_indices bool Whether the indices are guaranteed to be unique by the caller.

কোথায়:

  • N is required to be greater or equal to 1.
  • operands [ 0 ], ..., operands [ N-1 ] must all have the same dimensions.
  • updates [ 0 ], ..., updates [ N-1 ] must all have the same dimensions.
  • If N = 1 , Collate(T) is T .
  • If N > 1 , Collate(T_0, ..., T_N) is a tuple of N elements of type T .

If index_vector_dim is equal to scatter_indices.rank we implicitly consider scatter_indices to have a trailing 1 dimension.

We define update_scatter_dims of type ArraySlice<int64> as the set of dimensions in updates shape that are not in update_window_dims , in ascending order.

The arguments of scatter should follow these constraints:

  • Each updates array must have update_window_dims.size + scatter_indices.rank - 1 dimensions.

  • Bounds of dimension i in each updates array must conform to the following:

    • If i is present in update_window_dims (ie equal to update_window_dims [ k ] for some k ), then the bound of dimension i in updates must not exceed the corresponding bound of operand after accounting for the inserted_window_dims (ie adjusted_window_bounds [ k ], where adjusted_window_bounds contains the bounds of operand with the bounds at indices inserted_window_dims removed).
    • If i is present in update_scatter_dims (ie equal to update_scatter_dims [ k ] for some k ), then the bound of dimension i in updates must be equal to the corresponding bound of scatter_indices , skipping index_vector_dim (ie scatter_indices.shape.dims [ k ], if k < index_vector_dim and scatter_indices.shape.dims [ k+1 ] otherwise).
  • update_window_dims must be in ascending order, not have any repeating dimension numbers, and be in the range [0, updates.rank) .

  • inserted_window_dims must be in ascending order, not have any repeating dimension numbers, and be in the range [0, operand.rank) .

  • operand.rank must equal the sum of update_window_dims.size and inserted_window_dims.size .

  • scatter_dims_to_operand_dims.size must be equal to scatter_indices.shape.dims [ index_vector_dim ], and its values must be in the range [0, operand.rank) .

For a given index U in each updates array, the corresponding index I in the corresponding operands array into which this update has to be applied is computed as follows:

  1. Let G = { U [ k ] for k in update_scatter_dims }. Use G to look up an index vector S in the scatter_indices array such that S [ i ] = scatter_indices [Combine( G , i )] where Combine(A, b) inserts b at positions index_vector_dim into A.
  2. Create an index S in into operand using S by scattering S using the scatter_dims_to_operand_dims map. আরো আনুষ্ঠানিকভাবে:
    1. S in [ scatter_dims_to_operand_dims [ k ]] = S [ k ] if k < scatter_dims_to_operand_dims.size .
    2. S in [ _ ] = 0 otherwise.
  3. Create an index W in into each operands array by scattering the indices at update_window_dims in U according to inserted_window_dims . আরো আনুষ্ঠানিকভাবে:
    1. W in [ window_dims_to_operand_dims ( k )] = U [ k ] if k is in update_window_dims , where window_dims_to_operand_dims is the monotonic function with domain [ 0 , update_window_dims.size ) and range [ 0 , operand.rank ) \ inserted_window_dims . (For example, if update_window_dims.size is 4 , operand.rank is 6 , and inserted_window_dims is { 0 , 2 } then window_dims_to_operand_dims is { 01 , 13 , 24 , 35 }).
    2. W in [ _ ] = 0 otherwise.
  4. I is W in + S in where + is element-wise addition.

In summary, the scatter operation can be defined as follows.

  • Initialize output with operands , ie for all indices J , for all indices O in the operands [ J ] array:
    output [ J ][ O ] = operands [ J ][ O ]
  • For every index U in the updates [ J ] array and the corresponding index O in the operand [ J ] array, if O is a valid index for output :
    (output [ 0 ][ O ], ..., output [ N-1 ][ O ]) = update_computation ( output [ 0 ][ O ], ..., , output [ N-1 ][ O ], updates [ 0 ][ U ], ..., updates [ N-1 ][ U ])

The order in which updates are applied is non-deterministic. So, when multiple indices in updates refer to the same index in operands , the corresponding value in output will be non-deterministic.

Note that the first parameter that is passed into the update_computation will always be the current value from the output array and the second parameter will always be the value from the updates array. This is important specifically for cases when the update_computation is not commutative .

If indices_are_sorted is set to true then XLA can assume that scatter_indices are sorted (in ascending order, after scattering its values according to scatter_dims_to_operand_dims ) by the user. If they are not then the semantics are implementation defined.

If unique_indices is set to true then XLA can assume that all elements scattered to are unique. So XLA could use non-atomic operations. If unique_indices is set to true and the indices being scattered to are not unique then the semantics is implementation defined.

Informally, the scatter op can be viewed as an inverse of the gather op, ie the scatter op updates the elements in the input that are extracted by the corresponding gather op.

For a detailed informal description and examples, refer to the "Informal Description" section under Gather .

For StableHLO information see StableHLO - scatter .

Scatter - Example 1 - StableHLO

An example of Scatter dataflow for StableHLO

In the above image, each row of the table is an example of one update index example. Let's review stepwise from left(Update Index) to right(Result Index):

Input) input has shape S32[2,3,4,2]. scatter_indices have shape S64[2,2,3,2]. updates have shape S32[2,2,3,1,2].

Update Index) As part of the input we are given update_window_dims:[3,4] . This tell us that updates 's dim 3 and dim 4 are window dimensions, highlighted in yellow. This allows us to derive that update_scatter_dims = [0,1,2].

Update Scatter Index) Shows us the extracted updated_scatter_dims for each. (The non-yellow of column Update Index)

Start Index) Looking at the scatter_indices tensor image we can see that our values from the previous step (Update scatter Index), give us the location of the start index. From index_vector_dim we are also told the dimension of the starting_indices that contains the starting indices, which for scatter_indices is dim 3 with a size 2.

Full Start Index) scatter_dims_to_operand_dims = [2,1] tells us the first element of the index vector goes to operand dim 2. The second element of the index vector goes to operand dim 1. The remaining operand dimensions are filled with 0.

Full Batching Index) We can see the purple highlighted area is shown in this column(full batching index), the update scatter index column, and update index column.

Full Window Index) Computed from the update_window_dimensions [3,4].

Result Index) The addition of Full Start Index, Full Batching Index, and Full Window Index in the operand tensor. Notice the green highlighted regions correspond to the operand figure as well. The last row is skipped because it falls outside of operand tensor.

নির্বাচন করুন

See also XlaBuilder::Select .

Constructs an output array from elements of two input arrays, based on the values of a predicate array.

Select(pred, on_true, on_false)

যুক্তি টাইপ শব্দার্থবিদ্যা
pred XlaOp array of type PRED
on_true XlaOp array of type T
on_false XlaOp array of type T

The arrays on_true and on_false must have the same shape. This is also the shape of the output array. The array pred must have the same dimensionality as on_true and on_false , with the PRED element type.

For each element P of pred , the corresponding element of the output array is taken from on_true if the value of P is true , and from on_false if the value of P is false . As a restricted form of broadcasting , pred can be a scalar of type PRED . In this case, the output array is taken wholly from on_true if pred is true , and from on_false if pred is false .

Example with non-scalar pred :

let pred: PRED[4] = {true, false, false, true};
let v1: s32[4] = {1, 2, 3, 4};
let v2: s32[4] = {100, 200, 300, 400};
==>
Select(pred, v1, v2) = s32[4]{1, 200, 300, 4};

Example with scalar pred :

let pred: PRED = true;
let v1: s32[4] = {1, 2, 3, 4};
let v2: s32[4] = {100, 200, 300, 400};
==>
Select(pred, v1, v2) = s32[4]{1, 2, 3, 4};

Selections between tuples are supported. Tuples are considered to be scalar types for this purpose. If on_true and on_false are tuples (which must have the same shape!) then pred has to be a scalar of type PRED .

For StableHLO information see StableHLO - select

SelectAndScatter

See also XlaBuilder::SelectAndScatter .

This operation can be considered as a composite operation that first computes ReduceWindow on the operand array to select an element from each window, and then scatters the source array to the indices of the selected elements to construct an output array with the same shape as the operand array. The binary select function is used to select an element from each window by applying it across each window, and it is called with the property that the first parameter's index vector is lexicographically less than the second parameter's index vector. The select function returns true if the first parameter is selected and returns false if the second parameter is selected, and the function must hold transitivity (ie, if select(a, b) and select(b, c) are true , then select(a, c) is also true ) so that the selected element does not depend on the order of the elements traversed for a given window.

The function scatter is applied at each selected index in the output array. It takes two scalar parameters:

  1. Current value at the selected index in the output array
  2. The scatter value from source that applies to the selected index

It combines the two parameters and returns a scalar value that's used to update the value at the selected index in the output array. Initially, all indices of the output array are set to init_value .

The output array has the same shape as the operand array and the source array must have the same shape as the result of applying a ReduceWindow operation on the operand array. SelectAndScatter can be used to backpropagate the gradient values for a pooling layer in a neural network.

SelectAndScatter(operand, select, window_dimensions, window_strides, padding, source, init_value, scatter)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp array of type T over which the windows slide
select XlaComputation binary computation of type T, T -> PRED , to apply to all elements in each window; returns true if the first parameter is selected and returns false if the second parameter is selected
window_dimensions ArraySlice<int64> array of integers for window dimension values
window_strides ArraySlice<int64> array of integers for window stride values
padding Padding padding type for window (Padding::kSame or Padding::kValid)
source XlaOp array of type T with the values to scatter
init_value XlaOp scalar value of type T for the initial value of the output array
scatter XlaComputation binary computation of type T, T -> T , to apply each scatter source element with its destination element

The figure below shows examples of using SelectAndScatter , with the select function computing the maximal value among its parameters. Note that when the windows overlap, as in the figure (2) below, an index of the operand array may be selected multiple times by different windows. In the figure, the element of value 9 is selected by both of the top windows (blue and red) and the binary addition scatter function produces the output element of value 8 (2 + 6).

The evaluation order of the scatter function is arbitrary and may be non-deterministic. Therefore, the scatter function should not be overly sensitive to reassociation. See the discussion about associativity in the context of Reduce for more details.

For StableHLO information see StableHLO - select_and_scatter .

পাঠান

See also XlaBuilder::Send .

Send , SendWithTokens , and SendToHost are operations that serve as communication primitives in HLO. These ops typically appear in HLO dumps as part of low-level input/output or cross-device transfer, but they are not intended to be constructed manually by end users.

Send(operand, handle)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp data to send (array of type T)
handle ChannelHandle unique identifier for each send/recv pair

Sends the given operand data to a Recv instruction in another computation that shares the same channel handle. Does not return any data.

Similar to the Recv operation, the client API of Send operation represents synchronous communication, and is internally decomposed into 2 HLO instructions ( Send and SendDone ) to enable asynchronous data transfers. See also HloInstruction::CreateSend and HloInstruction::CreateSendDone .

Send(HloInstruction operand, int64 channel_id)

Initiates an asynchronous transfer of the operand to the resources allocated by the Recv instruction with the same channel id. Returns a context, which is used by a following SendDone instruction to wait for the completion of the data transfer. The context is a tuple of {operand (shape), request identifier (U32)} and it can only be used by a SendDone instruction.

For StableHLO information see StableHLO - send .

SendDone

See also HloInstruction::CreateSendDone .

SendDone(HloInstruction context)

Given a context created by a Send instruction, waits for the data transfer to complete. The instruction does not return any data.

Scheduling of channel instructions

The execution order of the 4 instructions for each channel ( Recv , RecvDone , Send , SendDone ) is as below.

  • Recv happens before Send
  • Send happens before RecvDone
  • Recv happens before RecvDone
  • Send happens before SendDone

When the backend compilers generate a linear schedule for each computation that communicates via channel instructions, there must not be cycles across the computations. For example, below schedules lead to deadlocks.

SetDimensionSize

See also XlaBuilder::SetDimensionSize .

Sets the dynamic size of XlaOp's given dimension. The operand must be array shaped.

SetDimensionSize(operand, val, dimension)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp n dimensional input array.
val XlaOp int32 representing the runtime dynamic size.
dimension int64 A value in the interval [0, n) that specifies the dimension.

Pass through the operand as result, with dynamic dimension tracked by the compiler.

Padded values will be ignored by downstream reduction ops.

let v: f32[10] = f32[10]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
let five: s32 = 5;
let six: s32 = 6;

// Setting dynamic dimension size doesn't change the upper bound of the static
// shape.
let padded_v_five: f32[10] = set_dimension_size(v, five, /*dimension=*/0);
let padded_v_six: f32[10] = set_dimension_size(v, six, /*dimension=*/0);

// sum == 1 + 2 + 3 + 4 + 5
let sum:f32[] = reduce_sum(padded_v_five);
// product == 1 * 2 * 3 * 4 * 5
let product:f32[] = reduce_product(padded_v_five);

// Changing padding size will yield different result.
// sum == 1 + 2 + 3 + 4 + 5 + 6
let sum:f32[] = reduce_sum(padded_v_six);

ShiftLeft

See also XlaBuilder::ShiftLeft .

Performs element-wise left-shift operation on lhs by rhs number of bits.

ShiftLeft(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for ShiftLeft:

ShiftLeft(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - shift_left .

ShiftRightArithmetic

See also XlaBuilder::ShiftRightArithmetic .

Performs element-wise arithmetic right-shift operation on lhs by rhs number of bits.

ShiftRightArithmetic(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for ShiftRightArithmetic:

ShiftRightArithmetic(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - shift_right_arithmetic .

ShiftRightLogical

See also XlaBuilder::ShiftRightLogical .

Performs element-wise logical right-shift operation on lhs by rhs number of bits.

ShiftRightLogical(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for ShiftRightLogical:

ShiftRightLogical(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - shift_right_logical .

সাইন

See also XlaBuilder::Sign .

Sign(operand) Element-wise sign operation x -> sgn(x) where

\[\text{sgn}(x) = \begin{cases} -1 & x < 0\\ -0 & x = -0\\ NaN & x = NaN\\ +0 & x = +0\\ 1 & x > 0 \end{cases}\]

using the comparison operator of the element type of operand .

Sign(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

For StableHLO information see StableHLO - sign .

পাপ

Sin(operand) Element-wise sine x -> sin(x) .

See also XlaBuilder::Sin .

Sin(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Sin also supports the optional result_accuracy argument:

Sin(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

For StableHLO information see StableHLO - sine .

স্লাইস

See also XlaBuilder::Slice .

Slicing extracts a sub-array from the input array. The sub-array has the same number of dimensions as the input and contains the values inside a bounding box within the input array where the dimensions and indices of the bounding box are given as arguments to the slice operation.

Slice(operand, start_indices, limit_indices, strides)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp N dimensional array of type T
start_indices ArraySlice<int64> List of N integers containing the starting indices of the slice for each dimension. Values must be greater than or equal to zero.
limit_indices ArraySlice<int64> List of N integers containing the ending indices (exclusive) for the slice for each dimension. Each value must be greater than or equal to the respective start_indices value for the dimension and less than or equal to the size of the dimension.
strides ArraySlice<int64> List of N integers that decides the input stride of the slice. The slice picks every strides[d] element in dimension d .

1-dimensional example:

let a = {0.0, 1.0, 2.0, 3.0, 4.0}
Slice(a, {2}, {4})
// Result: {2.0, 3.0}

2-dimensional example:

let b =
 { {0.0,  1.0,  2.0},
   {3.0,  4.0,  5.0},
   {6.0,  7.0,  8.0},
   {9.0, 10.0, 11.0} }

Slice(b, {2, 1}, {4, 3})
// Result:
//   { { 7.0,  8.0},
//     {10.0, 11.0} }

For StableHLO information see StableHLO - slice .

সাজান

See also XlaBuilder::Sort .

Sort(operands, comparator, dimension, is_stable)

যুক্তি টাইপ শব্দার্থবিদ্যা
operands ArraySlice<XlaOp> The operands to sort.
comparator XlaComputation The comparator computation to use.
dimension int64 The dimension along which to sort.
is_stable bool Whether stable sorting should be used.

If only one operand is provided:

  • If the operand is a 1-dimensional tensor (an array), the result is a sorted array. If you want to sort the array into ascending order, the comparator should perform a less-than comparison. Formally, after the array is sorted, it holds for all index positions i, j with i < j that either comparator(value[i], value[j]) = comparator(value[j], value[i]) = false or comparator(value[i], value[j]) = true .

  • If the operand has higher number of dimensions, the operand is sorted along the provided dimension. For example, for a 2-dimensional tensor (a matrix), a dimension value of 0 will independently sort every column, and a dimension value of 1 will independently sort each row. If no dimension number is provided, then the last dimension is chosen by default. For the dimension which is sorted, the same sorting order applies as in the 1-dimensional case.

If n > 1 operands are provided:

  • All n operands must be tensors with the same dimensions. The element types of the tensors may be different.

  • All operands are sorted together, not individually. Conceptually the operands are treated as a tuple. When checking whether the elements of each operand at index positions i and j need to be swapped, the comparator is called with 2 * n scalar parameters, where parameter 2 * k corresponds to the value at position i from the k-th operand, and parameter 2 * k + 1 corresponds to the value at position j from the k-th operand. Usually, the comparator would thus compare parameters 2 * k and 2 * k + 1 with each other and possibly use other parameter pairs as tie breakers.

  • The result is a tuple that consists of the operands in sorted order (along the provided dimension, as above). The i-th operand of the tuple corresponds to the i-th operand of Sort.

For example, if there are three operands operand0 = [3, 1] , operand1 = [42, 50] , operand2 = [-3.0, 1.1] , and the comparator compares only the values of operand0 with less-than, then the output of the sort is the tuple ([1, 3], [50, 42], [1.1, -3.0]) .

If is_stable is set to true, the sort is guaranteed to be stable, that is, if there are elements which are considered to be equal by the comparator, the relative order of the equal values is preserved. Two elements e1 and e2 are equal if and only if comparator(e1, e2) = comparator(e2, e1) = false . By default, is_stable is set to false.

For StableHLO information see StableHLO - sort .

Sqrt

See also XlaBuilder::Sqrt .

Element-wise square root operation x -> sqrt(x) .

Sqrt(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Sqrt also supports the optional result_accuracy argument:

Sqrt(operand, result_accuracy)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

For StableHLO information see StableHLO - sqrt .

উপ

See also XlaBuilder::Sub .

Performs element-wise subtraction of lhs and rhs .

Sub(lhs, rhs)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for Sub:

Sub(lhs,rhs, broadcast_dimensions)

যুক্তি টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - subtract .

ট্যান

See also XlaBuilder::Tan .

Element-wise tangent x -> tan(x) .

Tan(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Tan also supports the optional result_accuracy argument:

Tan(operand, result_accuracy)

Arguments টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

For StableHLO information see StableHLO - tan .

তানহ

See also XlaBuilder::Tanh .

Element-wise hyperbolic tangent x -> tanh(x) .

Tanh(operand)

যুক্তি টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function

Tanh also supports the optional result_accuracy argument:

Tanh(operand, result_accuracy)

Arguments টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to the function
result_accuracy optional ResultAccuracy The types of accuracy the user can request for unary ops with multiple implementations

For more information on result_accuracy see Result Accuracy .

For StableHLO information see StableHLO - tanh .

টপকে

See also XlaBuilder::TopK .

TopK finds the values and indices of the k largest or smallest elements for the last dimension of the given tensor.

TopK(operand, k, largest)

Arguments টাইপ শব্দার্থবিদ্যা
operand XlaOp The tensor from which to extract the top k elements. The tensor must have greater or equal to one dimensions. The size of the last dimension of the tensor must be greater or equal to k .
k int64 The number of elements to extract.
largest bool Whether to extract the largest or smallest k elements.

For a 1-dimensional input tensor (an array), finds the k largest or smallest entries in the array and outputs a tuple of two arrays (values, indices) . Thus values[j] is the j -th largest/smallest entry in operand , and its index is indices[j] .

For an input tensor with more than 1 dimension, computes the top k entries along the last dimension, preserving all other dimensions (rows) in the output. Thus, for an operand of shape [A, B, ..., P, Q] where Q >= k the output is a tuple (values, indices) where:

values.shape = indices.shape = [A, B, ..., P, k]

If two elements within a row are equal, the lower-index element appears first.

স্থানান্তর

See also the tf.reshape operation.

Transpose(operand, permutation)

Arguments টাইপ শব্দার্থবিদ্যা
operand XlaOp The operand to transpose.
permutation ArraySlice<int64> How to permute the dimensions.

Permutes the operand dimensions with the given permutation, so ∀ i . 0 ≤ i < number of dimensions ⇒ input_dimensions[permutation[i]] = output_dimensions[i] .

This is the same as Reshape(operand, permutation, Permute(permutation, operand.shape.dimensions)).

For StableHLO information see StableHLO - transpose .

TriangularSolve

See also XlaBuilder::TriangularSolve .

Solves systems of linear equations with lower or upper triangular coefficient matrices by forward- or back-substitution. Broadcasting along leading dimensions, this routine solves one of the matrix systems op(a) * x = b , or x * op(a) = b , for the variable x , given a and b , where op(a) is either op(a) = a , or op(a) = Transpose(a) , or op(a) = Conj(Transpose(a)) .

TriangularSolve(a, b, left_side, lower, unit_diagonal, transpose_a)

Arguments টাইপ শব্দার্থবিদ্যা
a XlaOp a > 2 dimensional array of a complex or floating-point type with shape [..., M, M] .
b XlaOp a > 2 dimensional array of the same type with shape [..., M, K] if left_side is true, [..., K, M] otherwise.
left_side bool indicates whether to solve a system of the form op(a) * x = b ( true ) or x * op(a) = b ( false ).
lower bool whether to use the upper or lower triangle of a .
unit_diagonal bool if true , the diagonal elements of a are assumed to be 1 and not accessed.
transpose_a Transpose whether to use a as is, transpose it or take its conjugate transpose.

Input data is read only from the lower/upper triangle of a , depending on the value of lower . Values from the other triangle are ignored. Output data is returned in the same triangle; the values in the other triangle are implementation-defined and may be anything.

If the number of dimensions of a and b are greater than 2, they are treated as batches of matrices, where all except the minor 2 dimensions are batch dimensions. a and b must have equal batch dimensions.

For StableHLO information see StableHLO - triangular_solve .

টুপল

See also XlaBuilder::Tuple .

A tuple containing a variable number of data handles, each of which has its own shape.

Tuple(elements)

যুক্তি টাইপ শব্দার্থবিদ্যা
elements vector of XlaOp N array of type T

This is analogous to std::tuple in C++. Conceptually:

let v: f32[10] = f32[10]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
let s: s32 = 5;
let t: (f32[10], s32) = tuple(v, s);

Tuples can be deconstructed (accessed) via the GetTupleElement operation.

For StableHLO information see StableHLO - tuple .

যখন

See also XlaBuilder::While .

While(condition, body, init)

Arguments টাইপ শব্দার্থবিদ্যা
condition XlaComputation XlaComputation of type T -> PRED which defines the termination condition of the loop.
body XlaComputation XlaComputation of type T -> T which defines the body of the loop.
init T Initial value for the parameter of condition and body .

Sequentially executes the body until the condition fails. This is similar to a typical while loop in many other languages except for the differences and restrictions listed below.

  • A While node returns a value of type T , which is the result from the last execution of the body .
  • The shape of the type T is statically determined and must be the same across all iterations.

The T parameters of the computations are initialized with the init value in the first iteration and are automatically updated to the new result from body in each subsequent iteration.

One main use case of the While node is to implement the repeated execution of training in neural networks. Simplified pseudocode is shown below with a graph that represents the computation. The code can be found in while_test.cc . The type T in this example is a Tuple consisting of an int32 for the iteration count and a vector[10] for the accumulator. For 1000 iterations, the loop keeps adding a constant vector to the accumulator.

// Pseudocode for the computation.
init = {0, zero_vector[10]} // Tuple of int32 and float[10].
result = init;
while (result(0) < 1000) {
  iteration = result(0) + 1;
  new_vector = result(1) + constant_vector[10];
  result = {iteration, new_vector};
}

For StableHLO information see StableHLO - while .

Xor

See also XlaBuilder::Xor .

Performs element-wise XOR of lhs and rhs .

Xor(lhs, rhs)

Arguments টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T

The arguments' shapes have to be either similar or compatible. See the broadcasting documentation about what it means for shapes to be compatible. The result of an operation has a shape which is the result of broadcasting the two input arrays. In this variant, operations between arrays of different ranks are not supported, unless one of the operands is a scalar.

An alternative variant with different-dimensional broadcasting support exists for Xor:

Xor(lhs,rhs, broadcast_dimensions)

Arguments টাইপ শব্দার্থবিদ্যা
এলএইচএস XlaOp Left-hand-side operand: array of type T
rhs XlaOp Left-hand-side operand: array of type T
broadcast_dimension ArraySlice Which dimension in the target shape each dimension of the operand shape corresponds to

This variant of the operation should be used for arithmetic operations between arrays of different ranks (such as adding a matrix to a vector).

The additional broadcast_dimensions operand is a slice of integers specifying the dimensions to use for broadcasting the operands. The semantics are described in detail on the broadcasting page .

For StableHLO information see StableHLO - xor .